mlx5 fixes 2021-03-10
Subsystems (7)
From: Saeed Mahameed <[email protected]>
Hi Dave, Jakub
This series introduces some fixes to mlx5 driver. Please pull and let me know if there is any problem.
Thanks,
Saeed.
---
The following changes since commit 05a59d79793d482f628a31753c671f2e92178a21:
Merge git://git.kernel.org:/pub/scm/linux/kernel/git/netdev/net (2021-03-09 17:15:56 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2021-03-10
for you to fetch changes up to 84076c4c800d1be77199a139d65b8b136a61422e:
net/mlx5: DR, Fix potential shift wrapping of 32-bit value in STEv1 getter (2021-03-10 11:01:59 -0800)
----------------------------------------------------------------
mlx5-fixes-2021-03-10
----------------------------------------------------------------
Aya Levin (3):
net/mlx5e: Accumulate port PTP TX stats with other channels stats net/mlx5e: Set PTP channel pointer explicitly to NULL net/mlx5: Fix turn-off PPS command
Maor Dickman (2):
net/mlx5e: Don't match on Geneve options in case option masks are all zero net/mlx5: Disable VF tunnel TX offload if ignore_flow_level isn't supported
Maor Gottlieb (2):
net/mlx5: Set QP timestamp mode to default
RDMA/mlx5: Fix timestamp default mode
Maxim Mikityanskiy (2):
net/mlx5e: When changing XDP program without reset, take refs for XSK RQs net/mlx5e: Revert parameters on errors when changing PTP state without reset
Parav Pandit (2):
net/mlx5e: E-switch, Fix rate calculation division net/mlx5: SF, Correct vhca context size
Roi Dayan (2):
net/mlx5e: Check correct ip_version in decapsulation route resolution net/mlx5e: Fix error flow in change profile
Shay Drory (2):
net/mlx5: SF: Fix memory leak of work item net/mlx5: SF: Fix error flow of SFs allocation flow
Tariq Toukan (2):
net/mlx5e: Enforce minimum value check for ICOSQ size net/mlx5e: RX, Mind the MPWQE gaps when calculating offsets
Yevgeny Kliteynik (1):
net/mlx5: DR, Fix potential shift wrapping of 32-bit value in STEv1 getter
drivers/infiniband/hw/mlx5/qp.c | 18 ++++-- drivers/net/ethernet/mellanox/mlx5/core/en.h | 7 ++- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 8 +-- .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 3 +- .../ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 4 ++ .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 5 ++ drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 69 ++++++++++++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 1 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 +- .../net/ethernet/mellanox/mlx5/core/fpga/conn.c | 1 + .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 4 +- .../net/ethernet/mellanox/mlx5/core/lib/clock.c | 8 +-- .../net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +- .../mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h | 2 +- .../ethernet/mellanox/mlx5/core/sf/vhca_event.c | 1 + .../ethernet/mellanox/mlx5/core/steering/dr_send.c | 1 + .../mellanox/mlx5/core/steering/dr_ste_v1.c | 4 +- include/linux/mlx5/qp.h | 7 +++ 20 files changed, 106 insertions(+), 49 deletions(-)
PATCH 1/18 net/mlx5e: Enforce minimum value check for ICOSQ size
From: Tariq Toukan <[email protected]>
The ICOSQ size should not go below MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE. Enforce this where it's missing.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -2
@@ -2368,8 +2368,9 @@ static u8 mlx5e_build_icosq_log_wq_sz(struct mlx5e_params *params, {switch (params->rq_wq_type) {case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ : -return order_base_2 (MLX5E_UMR_WQEBBS ) + -mlx5e_get_rq_log_wq_sz (rqp->rqc); +return max_t (u8,MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE , +order_base_2 (MLX5E_UMR_WQEBBS ) + +mlx5e_get_rq_log_wq_sz (rqp->rqc));default :/* MLX5_WQ_TYPE_CYCLIC */ return MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE ; }
Signature · 1 line
2.29.2
PATCH 2/18 net/mlx5e: RX, Mind the MPWQE gaps when calculating offsets
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Since cited patch, MLX5E_REQUIRED_WQE_MTTS is not a power of two. Hence, usage of MLX5E_LOG_ALIGNED_MPWQE_PPW should be replaced, as it lost some accuracy. Use the designated macro to calculate the number of required MTTs.
This makes sure the solution in cited patch works properly.
While here, un-inline mlx5e_get_mpwqe_offset(), and remove the unused RQ parameter.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 7 ++++--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -3
@@ -92,14 +92,15 @@ struct page_pool; MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)#define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) -#define MLX5_MTT_OCTW (npages) (ALIGN(npages, 8) / 2) +#define MLX5_ALIGN_MTTS (mtts) (ALIGN(mtts, 8)) +#define MLX5_ALIGNED_MTTS_OCTW (mtts) ((mtts) / 2) +#define MLX5_MTT_OCTW (mtts) (MLX5_ALIGNED_MTTS_OCTW(MLX5_ALIGN_MTTS(mtts)))/* Add another page to MLX5E_REQUIRED_WQE_MTTS as a buffer between * WQEs, This page will absorb write overflow by the hardware, when * receiving packets larger than MTU. These oversize packets are * dropped by the driver at a later stage. */ -#define MLX5E_REQUIRED_WQE_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE + 1, 8)) -#define MLX5E_LOG_ALIGNED_MPWQE_PPW (ilog2(MLX5E_REQUIRED_WQE_MTTS)) +#define MLX5E_REQUIRED_WQE_MTTS (MLX5_ALIGN_MTTS(MLX5_MPWRQ_PAGES_PER_WQE + 1))#define MLX5E_REQUIRED_MTTS (wqes) (wqes * MLX5E_REQUIRED_WQE_MTTS)#define MLX5E_MAX_RQ_NUM_MTTS \ ((1 << 16) * 2)/* So that MLX5_MTT_OCTW(num_mtts) fits into u16 */
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -3
@@ -334,9 +334,9 @@ static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev *mdev, struct mlx5e_rq rq->wqe_overflow.addr); } -static inline u64 mlx5e_get_mpwqe_offset (struct mlx5e_rq *rq,u16 wqe_ix) +static u64 mlx5e_get_mpwqe_offset (u16 wqe_ix) { -return (wqe_ix <<MLX5E_LOG_ALIGNED_MPWQE_PPW ) <<PAGE_SHIFT ; +return MLX5E_REQUIRED_MTTS (wqe_ix) <<PAGE_SHIFT ; }static void mlx5e_init_frags_partition (struct mlx5e_rq *rq)
@@ -577,7 +577,7 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,mlx5_wq_ll_get_wqe (&rq->mpwqe.wq, i);u32 byte_count = rq->mpwqe.num_strides << rq->mpwqe.log_stride_sz; -u64 dma_offset =mlx5e_get_mpwqe_offset (rq, i); +u64 dma_offset =mlx5e_get_mpwqe_offset (i); wqe->data[0 ].addr =cpu_to_be64 (dma_offset + rq->buff.headroom); wqe->data[0 ].byte_count =cpu_to_be32 (byte_count);
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 -2
@@ -500,7 +500,6 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)struct mlx5e_icosq *sq = rq->icosq;struct mlx5_wq_cyc *wq = &sq->wq;struct mlx5e_umr_wqe *umr_wqe; -u16 xlt_offset = ix << (MLX5E_LOG_ALIGNED_MPWQE_PPW -1 );u16 pi;int err;int i;
@@ -531,7 +530,8 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix) umr_wqe->ctrl.opmod_idx_opcode =cpu_to_be32 ((sq->pc <<MLX5_WQE_CTRL_WQE_INDEX_SHIFT ) |MLX5_OPCODE_UMR ); - umr_wqe->uctrl.xlt_offset =cpu_to_be16 (xlt_offset); + umr_wqe->uctrl.xlt_offset = +cpu_to_be16 (MLX5_ALIGNED_MTTS_OCTW (MLX5E_REQUIRED_MTTS (ix))); sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info ) { .wqe_type =MLX5E_ICOSQ_WQE_UMR_RX ,
Signature · 1 line
2.29.2
PATCH 4/18 net/mlx5e: Set PTP channel pointer explicitly to NULL
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
When closing the PTP channel, set its pointer explicitly to NULL. PTP channel is opened on demand, the code verify the pointer validity before access. Nullify it when closing the PTP channel to avoid unexpected behavior.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -1
@@ -2503,8 +2503,10 @@ void mlx5e_close_channels(struct mlx5e_channels *chs) {int i; -if (chs->port_ptp) +if (chs->port_ptp) {mlx5e_port_ptp_close (chs->port_ptp); + chs->port_ptp =NULL ; + }for (i =0 ; i < chs->num; i++)mlx5e_close_channel (chs->c[i]);
Signature · 1 line
2.29.2
PATCH 3/18 net/mlx5e: Accumulate port PTP TX stats with other channels stats
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
In addition to .get_ethtool_stats, add port PTP TX stats to .ndo_get_stats64.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +9 -0
@@ -3811,6 +3811,15 @@ void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)for (j =0 ; j < priv->max_opened_tc; j++) {struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j]; + s->tx_packets += sq_stats->packets; + s->tx_bytes += sq_stats->bytes; + s->tx_dropped += sq_stats->dropped; + } + } +if (priv->port_ptp_opened) { +for (i =0 ; i < priv->max_opened_tc; i++) { +struct mlx5e_sq_stats *sq_stats = &priv->port_ptp_stats.sq[i]; + s->tx_packets += sq_stats->packets; s->tx_bytes += sq_stats->bytes; s->tx_dropped += sq_stats->dropped;
Signature · 1 line
2.29.2
PATCH 5/18 net/mlx5e: When changing XDP program without reset, take refs for XSK RQs
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
Each RQ (including XSK RQs) takes a reference to the XDP program. When an XDP program is attached or detached, the channels and queues are recreated, however, there is a special flow for changing an active XDP program to another one. In that flow, channels and queues stay alive, but the refcounts of the old and new XDP programs are adjusted. This flow didn't increment refcount by the number of active XSK RQs, and this commit fixes it.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -1
@@ -4695,8 +4695,10 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)struct mlx5e_channel *c = priv->channels.c[i];mlx5e_rq_replace_xdp_prog (&c->rq, prog); -if (test_bit (MLX5E_CHANNEL_STATE_XSK , c->state)) +if (test_bit (MLX5E_CHANNEL_STATE_XSK , c->state)) { +bpf_prog_inc (prog);mlx5e_rq_replace_xdp_prog (&c->xskrq, prog); + } } unlock:
Signature · 1 line
2.29.2
PATCH 6/18 net/mlx5e: Revert parameters on errors when changing PTP state without reset
In reply to Saeed MahameedFrom: Maxim Mikityanskiy <[email protected]>
Port timestamping for PTP can be enabled/disabled while the channels are closed. In that case mlx5e_safe_switch_channels is skipped, and the preactivate hook is called directly. However, if that hook returns an error, the channel parameters must be reverted back to their old values. This commit adds missing handling on this case.
--- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +5 -0
@@ -2014,8 +2014,13 @@ static int set_pflag_tx_port_ts(struct net_device *netdev, bool enable)*/ if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) { +struct mlx5e_params old_params; + + old_params = priv->channels.params; priv->channels.params = new_channels.params; err =mlx5e_num_channels_changed (priv); +if (err) + priv->channels.params = old_params; goto out; }
Signature · 1 line
2.29.2
PATCH 7/18 net/mlx5e: Don't match on Geneve options in case option masks are all zero
In reply to Saeed MahameedFrom: Maor Dickman <[email protected]>
The cited change added offload support for Geneve options without verifying the validity of the options masks, this caused offload of rules with match on Geneve options with class,type and data masks which are zero to fail.
Fix by ignoring the match on Geneve options in case option masks are all zero.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c +4 -0
@@ -227,6 +227,10 @@ static int mlx5e_tc_tun_parse_geneve_options(struct mlx5e_priv *priv, option_key = (struct geneve_opt *)&enc_opts.key->data[0 ]; option_mask = (struct geneve_opt *)&enc_opts.mask->data[0 ]; +if (option_mask->opt_class ==0 && option_mask->type ==0 && + !memchr_inv (option_mask->opt_data,0 , option_mask->length *4 )) +return 0 ; +if (option_key->length > max_tlv_option_data_len) {NL_SET_ERR_MSG_MOD (extack,"Matching on GENEVE options: unsupported option len" );
Signature · 1 line
2.29.2
PATCH 8/18 net/mlx5: Fix turn-off PPS command
In reply to Saeed MahameedFrom: Aya Levin <[email protected]>
Fix a bug of uninitialized pin index when trying to turn off PPS out.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +4 -4
@@ -495,15 +495,15 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,return -EINVAL ; field_select =MLX5_MTPPS_FS_ENABLE ; + pin =ptp_find_pin (clock->ptp,PTP_PF_PEROUT , rq->perout.index); +if (pin <0 ) +return -EBUSY ; +if (on) {bool rt_mode =mlx5_real_time_mode (mdev);u32 nsec;s64 sec; - pin =ptp_find_pin (clock->ptp,PTP_PF_PEROUT , rq->perout.index); -if (pin <0 ) -return -EBUSY ; - pin_mode =MLX5_PIN_MODE_OUT ; pattern =MLX5_OUT_PATTERN_PERIODIC ; ts.tv_sec = rq->perout.period.sec;
Signature · 1 line
2.29.2
PATCH 9/18 net/mlx5e: Check correct ip_version in decapsulation route resolution
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
flow_attr->ip_version has the matching that should be done inner/outer. When working with chains, decapsulation is done on chain0 and next chain match on outer header which is the original inner which could be ipv4. So in tunnel route resolution we cannot use that to know which ip version we are at so save tun_ip_version when parsing the tunnel match and use that.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +4 -4
@@ -685,14 +685,14 @@ int mlx5e_tc_tun_route_lookup(struct mlx5e_priv *priv,u16 vport_num;int err =0 ; -if (flow_attr->ip_version ==4 ) { +if (flow_attr->tun_ip_version ==4 ) {/* Addresses are swapped for decap */ attr.fl.fl4.saddr = esw_attr->rx_tun_attr->dst_ip.v4; attr.fl.fl4.daddr = esw_attr->rx_tun_attr->src_ip.v4; err =mlx5e_route_lookup_ipv4_get (priv, priv->netdev, &attr); }#if IS_ENABLED (CONFIG_INET ) &&IS_ENABLED (CONFIG_IPV6 ) - else if (flow_attr->ip_version == 6) { + else if (flow_attr->tun_ip_version == 6) {/* Addresses are swapped for decap */ attr.fl.fl6.saddr = esw_attr->rx_tun_attr->dst_ip.v6; attr.fl.fl6.daddr = esw_attr->rx_tun_attr->src_ip.v6;
@@ -718,10 +718,10 @@ int mlx5e_tc_tun_route_lookup(struct mlx5e_priv *priv, esw_attr->rx_tun_attr->decap_vport = vport_num; out: -if (flow_attr->ip_version ==4 ) +if (flow_attr->tun_ip_version ==4 )mlx5e_route_lookup_ipv4_put (&attr);#if IS_ENABLED (CONFIG_INET ) &&IS_ENABLED (CONFIG_IPV6 ) - else if (flow_attr->ip_version == 6) + else if (flow_attr->tun_ip_version == 6) mlx5e_route_lookup_ipv6_put(&attr);#endif return err;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +2 -1
@@ -89,6 +89,7 @@ int mlx5e_tc_set_attr_rx_tun(struct mlx5e_tc_flow *flow,* required to establish routing. */ flow_flag_set (flow,TUN_RX ); + flow->attr->tun_ip_version = ip_version;return 0 ; }
@@ -1091,7 +1092,7 @@ int mlx5e_attach_decap_route(struct mlx5e_priv *priv,if (err || !esw_attr->rx_tun_attr->decap_vport) goto out; - key.ip_version = attr->ip_version; + key.ip_version = attr->tun_ip_version;if (key.ip_version ==4 ) key.endpoint_ip.v4 = esw_attr->rx_tun_attr->dst_ip.v4;else
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -0
@@ -79,6 +79,7 @@ struct mlx5_flow_attr {u8 inner_match_level;u8 outer_match_level;u8 ip_version; +u8 tun_ip_version;u32 flags;union {struct mlx5_esw_flow_attr esw_attr[0 ];
Signature · 1 line
2.29.2
PATCH 10/18 net/mlx5: Disable VF tunnel TX offload if ignore_flow_level isn't supported
In reply to Saeed MahameedFrom: Maor Dickman <[email protected]>
VF tunnel TX traffic offload is adding flow which forward to flow tables with lower level, which isn't support on all FW versions and may cause firmware to fail with syndrome.
Fixed by enabling VF tunnel TX offload only if flow table capability ignore_flow_level is enabled.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -1
@@ -551,7 +551,8 @@ esw_setup_dests(struct mlx5_flow_destination *dest,if (!mlx5_eswitch_termtbl_required (esw, attr, flow_act, spec) &&MLX5_CAP_GEN (esw_attr->in_mdev, reg_c_preserve) && -mlx5_eswitch_vport_match_metadata_enabled (esw)) +mlx5_eswitch_vport_match_metadata_enabled (esw) && +MLX5_CAP_ESW_FLOWTABLE_FDB (esw->dev, ignore_flow_level)) attr->flags |=MLX5_ESW_ATTR_FLAG_SRC_REWRITE ;if (attr->dest_ft) {
Signature · 1 line
2.29.2
PATCH 11/18 net/mlx5e: Fix error flow in change profile
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move priv memset from init to cleanup to avoid double priv cleanup that can happen on profile change if also roolback fails. Add missing cleanup flow in mlx5e_netdev_attach_profile().
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 41 +++++++++++-------- .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 3 +- 2 files changed, 26 insertions(+), 18 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +24 -17
@@ -5488,8 +5488,6 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,struct net_device *netdev, struct mlx5_core_dev *mdev) { - memset(priv, 0, sizeof(*priv)); -/* priv init */ priv->mdev = mdev; priv->netdev = netdev;
@@ -5522,12 +5520,18 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv) {int i; +/* bail if change profile failed and also rollback failed */ +if (!priv->mdev) +return ; +destroy_workqueue (priv->wq);free_cpumask_var (priv->scratchpad.cpumask);for (i =0 ; i < priv->htb.max_qos_sqs; i++)kfree (priv->htb.qos_sq_stats[i]);kvfree (priv->htb.qos_sq_stats); + +memset (priv,0 ,sizeof (*priv)); } struct net_device *
@@ -5644,11 +5648,10 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv) }static int -mlx5e_netdev_attach_profile (struct mlx5e_priv *priv, +mlx5e_netdev_attach_profile (struct net_device *netdev,struct mlx5_core_dev *mdev,const struct mlx5e_profile *new_profile,void *new_ppriv) { -struct net_device *netdev = priv->netdev; -struct mlx5_core_dev *mdev = priv->mdev; +struct mlx5e_priv *priv =netdev_priv (netdev);int err; err =mlx5e_priv_init (priv, netdev, mdev);
@@ -5661,10 +5664,16 @@ mlx5e_netdev_attach_profile(struct mlx5e_priv *priv, priv->ppriv = new_ppriv; err = new_profile->init (priv->mdev, priv->netdev);if (err) -return err; + goto priv_cleanup; err =mlx5e_attach_netdev (priv);if (err) - new_profile->cleanup (priv); + goto profile_cleanup; +return err; + +profile_cleanup: + new_profile->cleanup (priv); +priv_cleanup: +mlx5e_priv_cleanup (priv);return err; }
@@ -5673,13 +5682,14 @@ int mlx5e_netdev_change_profile(struct mlx5e_priv *priv, {unsigned int new_max_nch =mlx5e_calc_max_nch (priv, new_profile);const struct mlx5e_profile *orig_profile = priv->profile; +struct net_device *netdev = priv->netdev; +struct mlx5_core_dev *mdev = priv->mdev;void *orig_ppriv = priv->ppriv;int err, rollback_err;/* sanity */ if (new_max_nch != priv->max_nch) { -netdev_warn (priv->netdev, -"%s: Replacing profile with different max channels\n" , +netdev_warn (netdev,"%s: Replacing profile with different max channels\n" , __func__);return -EINVAL ; }
@@ -5689,22 +5699,19 @@ int mlx5e_netdev_change_profile(struct mlx5e_priv *priv, priv->profile->cleanup (priv);mlx5e_priv_cleanup (priv); - err =mlx5e_netdev_attach_profile (priv, new_profile, new_ppriv); + err =mlx5e_netdev_attach_profile (netdev, mdev, new_profile, new_ppriv);if (err) {/* roll back to original profile */ -netdev_warn (priv->netdev,"%s: new profile init failed, %d\n" , - __func__, err); +netdev_warn (netdev,"%s: new profile init failed, %d\n" , __func__, err); goto rollback; }return 0 ; rollback: - rollback_err =mlx5e_netdev_attach_profile (priv, orig_profile, orig_ppriv); -if (rollback_err) { -netdev_err (priv->netdev, -"%s: failed to rollback to orig profile, %d\n" , + rollback_err =mlx5e_netdev_attach_profile (netdev, mdev, orig_profile, orig_ppriv); +if (rollback_err) +netdev_err (netdev,"%s: failed to rollback to orig profile, %d\n" , __func__, rollback_err); - }return err; }
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -1
@@ -694,6 +694,7 @@ static int mlx5i_check_required_hca_cap(struct mlx5_core_dev *mdev)static void mlx5_rdma_netdev_free (struct net_device *netdev) {struct mlx5e_priv *priv =mlx5i_epriv (netdev); +struct mlx5_core_dev *mdev = priv->mdev;struct mlx5i_priv *ipriv = priv->ppriv;const struct mlx5e_profile *profile = priv->profile;
@@ -702,7 +703,7 @@ static void mlx5_rdma_netdev_free(struct net_device *netdev)if (!ipriv->sub_interface) {mlx5i_pkey_qpn_ht_cleanup (netdev); -mlx5e_destroy_mdev_resources (priv->mdev); +mlx5e_destroy_mdev_resources (mdev); } }
Signature · 1 line
2.29.2
PATCH 14/18 net/mlx5e: E-switch, Fix rate calculation division
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
do_div() returns reminder, while cited patch wanted to use quotient.
Fix it by using quotient.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -1
@@ -4445,7 +4445,8 @@ static int apply_police_params(struct mlx5e_priv *priv, u64 rate,*/ if (rate) { rate = (rate *BITS_PER_BYTE ) +500000 ; - rate_mbps =max_t (u64,do_div (rate,1000000 ),1 ); +do_div (rate,1000000 ); + rate_mbps =max_t (u32, rate,1 ); } err =mlx5_esw_modify_vport_rate (esw, vport_num, rate_mbps);
Signature · 1 line
2.29.2
PATCH 12/18 net/mlx5: Set QP timestamp mode to default
In reply to Saeed MahameedFrom: Maor Gottlieb <[email protected]>
QPs which don't care from timestamp mode, should set the ts_format to default, otherwise the QP creation could be failed if the timestamp mode is not supported.
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c | 1 + include/linux/mlx5/qp.h | 7 +++++++ 4 files changed, 10 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c +1 -0
@@ -575,6 +575,7 @@ static int mlx5_fpga_conn_create_qp(struct mlx5_fpga_conn *conn,MLX5_SET (qpc, qpc, log_sq_size,ilog2 (conn->qp.sq.size));MLX5_SET (qpc, qpc, cqn_snd, conn->cq.mcq.cqn);MLX5_SET (qpc, qpc, cqn_rcv, conn->cq.mcq.cqn); +MLX5_SET (qpc, qpc, ts_format,mlx5_get_qp_default_ts (mdev));MLX5_SET64 (qpc, qpc, dbr_addr, conn->qp.wq_ctrl.db.dma);if (MLX5_CAP_GEN (mdev, cqe_version) ==1 )MLX5_SET (qpc, qpc, user_index,0xFFFFFF );
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +1 -0
@@ -233,6 +233,7 @@ int mlx5i_create_underlay_qp(struct mlx5e_priv *priv) } qpc =MLX5_ADDR_OF (create_qp_in, in, qpc); +MLX5_SET (qpc, qpc, ts_format,mlx5_get_qp_default_ts (priv->mdev));MLX5_SET (qpc, qpc, st,MLX5_QP_ST_UD );MLX5_SET (qpc, qpc, pm_state,MLX5_QP_PM_MIGRATED ); MLX5_SET(qpc, qpc, ulp_stateless_offload_mode,
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c +1 -0
@@ -169,6 +169,7 @@ static struct mlx5dr_qp *dr_create_rc_qp(struct mlx5_core_dev *mdev,MLX5_SET (qpc, qpc, log_rq_size,ilog2 (dr_qp->rq.wqe_cnt));MLX5_SET (qpc, qpc, rq_type,MLX5_NON_ZERO_RQ );MLX5_SET (qpc, qpc, log_sq_size,ilog2 (dr_qp->sq.wqe_cnt)); +MLX5_SET (qpc, qpc, ts_format,mlx5_get_qp_default_ts (mdev));MLX5_SET64 (qpc, qpc, dbr_addr, dr_qp->wq_ctrl.db.dma);if (MLX5_CAP_GEN (mdev, cqe_version) ==1 )MLX5_SET (qpc, qpc, user_index,0xFFFFFF );
include/linux/mlx5/qp.h +7 -0
@@ -547,4 +547,11 @@ static inline const char *mlx5_qp_state_str(int state) } } +static inline int mlx5_get_qp_default_ts (struct mlx5_core_dev *dev) +{ +return !MLX5_CAP_ROCE (dev, qp_ts_format) ? +MLX5_QPC_TIMESTAMP_FORMAT_FREE_RUNNING : +MLX5_QPC_TIMESTAMP_FORMAT_DEFAULT ; +} +#endif /* MLX5_QP_H */
Signature · 1 line
2.29.2
PATCH 13/18 RDMA/mlx5: Fix timestamp default mode
In reply to Saeed MahameedFrom: Maor Gottlieb <[email protected]>
1. Don't set the ts_format bit to default when it reserved - device is running in the old mode (free running).
2. XRC doesn't have a CQ therefore the ts format in the QP context should be default / free running.
3. Set ts_format to WQ.
--- drivers/infiniband/hw/mlx5/qp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +14 -4
@@ -1078,7 +1078,7 @@ static int _create_kernel_qp(struct mlx5_ib_dev *dev, qpc =MLX5_ADDR_OF (create_qp_in, *in, qpc);MLX5_SET (qpc, qpc, uar_page, uar_index); -MLX5_SET (qpc, qpc, ts_format,MLX5_QPC_TIMESTAMP_FORMAT_DEFAULT ); +MLX5_SET (qpc, qpc, ts_format,mlx5_get_qp_default_ts (dev->mdev));MLX5_SET (qpc, qpc, log_page_size, qp->buf.page_shift -MLX5_ADAPTER_PAGE_SHIFT );/* Set "fast registration enabled" for all kernel QPs */
@@ -1188,7 +1188,8 @@ static int get_rq_ts_format(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *send_cq) }return MLX5_RQC_TIMESTAMP_FORMAT_FREE_RUNNING ; } -return MLX5_RQC_TIMESTAMP_FORMAT_DEFAULT ; +return fr_supported ?MLX5_RQC_TIMESTAMP_FORMAT_FREE_RUNNING : +MLX5_RQC_TIMESTAMP_FORMAT_DEFAULT ; }static int get_sq_ts_format (struct mlx5_ib_dev *dev,struct mlx5_ib_cq *send_cq)
@@ -1206,7 +1207,8 @@ static int get_sq_ts_format(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *send_cq) }return MLX5_SQC_TIMESTAMP_FORMAT_FREE_RUNNING ; } -return MLX5_SQC_TIMESTAMP_FORMAT_DEFAULT ; +return fr_supported ?MLX5_SQC_TIMESTAMP_FORMAT_FREE_RUNNING : +MLX5_SQC_TIMESTAMP_FORMAT_DEFAULT ; } static int get_qp_ts_format(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *send_cq,
@@ -1217,7 +1219,8 @@ static int get_qp_ts_format(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *send_cq,MLX5_QP_TIMESTAMP_FORMAT_CAP_FREE_RUNNING ||MLX5_CAP_ROCE (dev->mdev, qp_ts_format) ==MLX5_QP_TIMESTAMP_FORMAT_CAP_FREE_RUNNING_AND_REAL_TIME ; -int ts_format =MLX5_QPC_TIMESTAMP_FORMAT_DEFAULT ; +int ts_format = fr_supported ?MLX5_QPC_TIMESTAMP_FORMAT_FREE_RUNNING : +MLX5_QPC_TIMESTAMP_FORMAT_DEFAULT ;if (recv_cq && recv_cq->create_flags &IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION )
@@ -1930,6 +1933,7 @@ static int create_xrc_tgt_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,if (qp->flags &IB_QP_CREATE_MANAGED_RECV )MLX5_SET (qpc, qpc, cd_slave_receive,1 ); +MLX5_SET (qpc, qpc, ts_format,mlx5_get_qp_default_ts (dev->mdev));MLX5_SET (qpc, qpc, rq_type,MLX5_SRQ_RQ );MLX5_SET (qpc, qpc, no_sq,1 );MLX5_SET (qpc, qpc, cqn_rcv,to_mcq (devr->c0)->mcq.cqn);
@@ -4873,6 +4877,7 @@ static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,struct mlx5_ib_dev *dev;int has_net_offloads;__be64 *rq_pas0; +int ts_format;void *in;void *rqc;void *wq;
@@ -4881,6 +4886,10 @@ static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd, dev =to_mdev (pd->device); + ts_format =get_rq_ts_format (dev,to_mcq (init_attr->cq)); +if (ts_format <0 ) +return ts_format; + inlen =MLX5_ST_SZ_BYTES (create_rq_in) +sizeof (u64) * rwq->rq_num_pas; in =kvzalloc (inlen,GFP_KERNEL );if (!in)
@@ -4890,6 +4899,7 @@ static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd, rqc =MLX5_ADDR_OF (create_rq_in, in, ctx);MLX5_SET (rqc, rqc, mem_rq_type,MLX5_RQC_MEM_RQ_TYPE_MEMORY_RQ_INLINE ); +MLX5_SET (rqc, rqc, ts_format, ts_format);MLX5_SET (rqc, rqc, user_index, rwq->user_index);MLX5_SET (rqc, rqc, cqn,to_mcq (init_attr->cq)->mcq.cqn);MLX5_SET (rqc, rqc, state,MLX5_RQC_STATE_RST );
Signature · 1 line
2.29.2
PATCH 15/18 net/mlx5: SF, Correct vhca context size
In reply to Saeed MahameedFrom: Parav Pandit <[email protected]>
Fix vhca context size as defined by device interface specification.
--- .../net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/mlx5_ifc_vhca_event.h +1 -1
@@ -20,7 +20,7 @@ struct mlx5_ifc_vhca_state_context_bits {u8 sw_function_id[0x20 ]; -u8 reserved_at_40[0x80 ]; +u8 reserved_at_40[0x40 ]; };struct mlx5_ifc_query_vhca_state_out_bits {
Signature · 1 line
2.29.2
PATCH 16/18 net/mlx5: SF: Fix memory leak of work item
In reply to Saeed MahameedFrom: Shay Drory <[email protected]>
Cited patch in the fixes tag missed to free the allocated work. Fix it by freeing the work after work execution.
--- drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c +1 -0
@@ -94,6 +94,7 @@ static void mlx5_vhca_state_work_handler(struct work_struct *_work)struct mlx5_core_dev *dev = notifier->dev;mlx5_vhca_event_notify (dev, &work->event); +kfree (work); } static int
Signature · 1 line
2.29.2
PATCH 17/18 net/mlx5: SF: Fix error flow of SFs allocation flow
In reply to Saeed MahameedFrom: Shay Drory <[email protected]>
When SF id is unavailable, code jumps to wrong label that accesses sw id array outside of its range.
Hence, when SF id is not allocated, avoid accessing such array.
--- drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +1 -1
@@ -64,7 +64,7 @@ int mlx5_sf_hw_table_sf_alloc(struct mlx5_core_dev *dev, u32 usr_sfnum) }if (sw_id == -ENOSPC ) { err = -ENOSPC ; - goto err; + goto exist_err; } hw_fn_id =mlx5_sf_sw_to_hw_id (table->dev, sw_id);
Signature · 1 line
2.29.2
PATCH 18/18 net/mlx5: DR, Fix potential shift wrapping of 32-bit value in STEv1 getter
In reply to Saeed MahameedFrom: Yevgeny Kliteynik <[email protected]>
Fix 32-bit variable shift wrapping in dr_ste_v1_get_miss_addr.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +2 -2
@@ -264,8 +264,8 @@ static void dr_ste_v1_set_miss_addr(u8 *hw_ste_p, u64 miss_addr)static u64 dr_ste_v1_get_miss_addr (u8 *hw_ste_p) {u64 index = - (MLX5_GET (ste_match_bwc_v1, hw_ste_p, miss_address_31_6) | -MLX5_GET (ste_match_bwc_v1, hw_ste_p, miss_address_39_32) <<26 ); + ((u64 )MLX5_GET (ste_match_bwc_v1, hw_ste_p, miss_address_31_6) | + ((u64 )MLX5_GET (ste_match_bwc_v1, hw_ste_p, miss_address_39_32)) <<26 );return index <<6 ; }
Signature · 1 line
2.29.2
Re: [net 13/18] RDMA/mlx5: Fix timestamp default mode
In reply to Saeed MahameedQuoted 8 lines · Saeed Mahameed
From: Maor Gottlieb <[email protected]>
1. Don't set the
ts_formatbit to default when it reserved - device is running in the old mode (free running).
2. XRC doesn't have a CQ therefore the ts format in the QP context should be default / free running.
3. Setts_formatto WQ.
Quoted 6 lines
Fixes 2fe8d4b87802 ("RDMA/mlx5: Fail QP creation if the device can not support the CQE TS")Signed-off-by Maor Gottlieb <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/infiniband/hw/mlx5/qp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
Jason
Re: [net 01/18] net/mlx5e: Enforce minimum value check for ICOSQ size
In reply to Saeed MahameedThis series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 11 lines · On Wed, 10 Mar 2021 11:03:25 -0800 you wrote:
From: Tariq Toukan <[email protected]>
The ICOSQ size should not go below
MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE. Enforce this where it's missing.Signed-off-by Tariq Toukan <[email protected]>Reviewed-by Maxim Mikityanskiy <[email protected]>Reviewed-by Saeed Mahameed <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>[...]
Here is the summary with links:
- [net,01/18] net/mlx5e: Enforce minimum value check for ICOSQ size
https://git.kernel.org/netdev/net/c/5115daa675cc - [net,02/18] net/mlx5e: RX, Mind the MPWQE gaps when calculating offsets https://git.kernel.org/netdev/net/c/d5dd03b26ba4 - [net,03/18] net/mlx5e: Accumulate port PTP TX stats with other channels stats https://git.kernel.org/netdev/net/c/354521eebd02 - [net,04/18] net/mlx5e: Set PTP channel pointer explicitly to NULL https://git.kernel.org/netdev/net/c/1c2cdf0b603a - [net,05/18] net/mlx5e: When changing XDP program without reset, take refs for XSK RQs https://git.kernel.org/netdev/net/c/e5eb01344e9b - [net,06/18] net/mlx5e: Revert parameters on errors when changing PTP state without reset https://git.kernel.org/netdev/net/c/74640f09735f - [net,07/18] net/mlx5e: Don't match on Geneve options in case option masks are all zero https://git.kernel.org/netdev/net/c/385d40b042e6 - [net,08/18] net/mlx5: Fix turn-off PPS command https://git.kernel.org/netdev/net/c/55affa97d675 - [net,09/18] net/mlx5e: Check correct ip_version in decapsulation route resolution https://git.kernel.org/netdev/net/c/1e74152ed065 - [net,10/18] net/mlx5: Disable VF tunnel TX offload if ignore_flow_level isn't supported https://git.kernel.org/netdev/net/c/f574531a0b77 - [net,11/18] net/mlx5e: Fix error flow in change profile https://git.kernel.org/netdev/net/c/469549e4778a - [net,12/18] net/mlx5: Set QP timestamp mode to default https://git.kernel.org/netdev/net/c/4806f1e2fee8 - [net,13/18] RDMA/mlx5: Fix timestamp default mode https://git.kernel.org/netdev/net/c/8256c69b2d9c - [net,14/18] net/mlx5e: E-switch, Fix rate calculation division https://git.kernel.org/netdev/net/c/8b90d897823b - [net,15/18] net/mlx5: SF, Correct vhca context size https://git.kernel.org/netdev/net/c/6a3717544ce9 - [net,16/18] net/mlx5: SF: Fix memory leak of work item https://git.kernel.org/netdev/net/c/6fa37d66ef2d - [net,17/18] net/mlx5: SF: Fix error flow of SFs allocation flow https://git.kernel.org/netdev/net/c/dc694f11a759 - [net,18/18] net/mlx5: DR, Fix potential shift wrapping of 32-bit value in STEv1 getter https://git.kernel.org/netdev/net/c/84076c4c800d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [net 13/18] RDMA/mlx5: Fix timestamp default mode
In reply to Saeed MahameedQuoted 8 lines · Saeed Mahameed
From: Maor Gottlieb <[email protected]>
1. Don't set the
ts_formatbit to default when it reserved - device is running in the old mode (free running).
2. XRC doesn't have a CQ therefore the ts format in the QP context should be default / free running.
3. Setts_formatto WQ.
Quoted 7 lines
Fixes 2fe8d4b87802 ("RDMA/mlx5: Fail QP creation if the device can not support the CQE TS")Signed-off-by Maor Gottlieb <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- drivers/infiniband/hw/mlx5/qp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
I reviewed it too.
Thanks,