Mellanox, mlx5 misc updates 2019-01-25
Hi Dave,
This series provides some 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 30e5c2c6bf285d93dee4c45f23da95d7d50b125a:
net: Revert devlink health changes. (2019-01-25 10:53:23 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2019-01-25
for you to fetch changes up to b832d4fdf105b5464d786e321e3c9e012e67cdfb:
net/mlx5e: Reuse fold sw stats in representors (2019-01-25 12:16:15 -0800)
----------------------------------------------------------------
mlx5-updates-2019-01-25
This series provides some updates to mlx5 driver,
From Tariq,
1) Make sure RX packet header does not cross page boundary To avoid page boundary crossing, use stride size that fits the maximum possible header. Stride is increased form 64B to 256B.
2) CQ struct cleanup: Take CQ decompress fields into a separate structure
From Moshe,
3) Expand XPS cpumask to cover all online cpus
From Jason Gunthorpe and Tariq:
4) Compilation warning cleanup
From Or,
5) Add trace points for flow tables create/destroy
From Saeed,
6) Software stats update/folding improvements
this also solves a compilation warning on 32bit systems that was reported last release cycle by Arnd and Andrew.
Thanks,
Saeed.
----------------------------------------------------------------
Jason Gunthorpe (1):
net/mlx5e: Return the allocated flow directly from __mlx5e_add_fdb_flow
Moshe Shemesh (1):
net/mlx5e: Expand XPS cpumask to cover all online cpus
Or Gerlitz (1):
net/mlx5: Add trace points for flow tables create/destroy
Saeed Mahameed (2):
net/mlx5e: Separate between ethtool and netdev software stats folding net/mlx5e: Reuse fold sw stats in representors
Tariq Toukan (3):
net/mlx5e: RX, Make sure packet header does not cross page boundary net/mlx5e: Take CQ decompress fields into a separate structure net/mlx5e: Present the representors SW stats when state is not opened
.../mellanox/mlx5/core/diag/fs_tracepoint.c | 2 + .../mellanox/mlx5/core/diag/fs_tracepoint.h | 35 +++++ drivers/net/ethernet/mellanox/mlx5/core/en.h | 28 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 67 +++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 39 ++---- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 154 ++++++++++----------- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 6 +- drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 29 ++-- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 2 + 10 files changed, 211 insertions(+), 152 deletions(-)
PATCH 1/8 net/mlx5e: RX, Make sure packet header does not cross page boundary
From: Tariq Toukan <[email protected]>
In the non-linear SKB memory scheme of Striding RQ, a packet header could cross page boundary. This requires special care in fast path that costs LoC, additional runtime instructions and branches.
It could happen when the header (up to 256B) does not fit in a single stride. Avoid this by working with a stride size that fits the maximum possible header. Stride is increased form 64B to 256B.
Performance:
Tested packet rate for UDP streams, single ring, on ConnectX-5.
Configuration:
Set Striding RQ and LRO ON (to enabled the non-linear SKB scheme). GRO OFF, early drop by TC rule.
64B: 4x worse memory utilization, no page-crossers headers
- No degradation (5,887,305 pps).
- The reduction in memory utilization is compensated by the saving of branches tests.
192B: 1.33x worse memory utilization, avoid page-crossers headers
- Before: 5,727,252. After: 5,777,037. ~1% gain.
256B: Same memory util, no page-crossers
- Before: 5,691,885. After: 5,748,007. ~1% gain.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 11 +++----- .../net/ethernet/mellanox/mlx5/core/en_main.c | 3 +-- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 27 +++---------------- 3 files changed, 9 insertions(+), 32 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +4 -7
@@ -76,15 +76,14 @@ struct page_pool;#define MLX5_SKB_FRAG_SZ (len) (SKB_DATA_ALIGN(len) + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) +#define MLX5E_RX_MAX_HEAD (256) +#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ (mdev) \ (6 + MLX5_CAP_GEN(mdev, cache_line_128byte))/* HW restriction */ #define MLX5_MPWRQ_LOG_STRIDE_SZ (mdev, req) \ max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req) -#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ (mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6) -#define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ (mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8) -#define MLX5E_MPWQE_STRIDE_SZ (mdev, cqe_cmprs) \ - (cqe_cmprs ? MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) : \ - MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev)) +#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ (mdev) \ + MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, order_base_2(MLX5E_RX_MAX_HEAD))#define MLX5_MPWRQ_LOG_WQE_SZ 18#define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
@@ -119,8 +118,6 @@ struct page_pool;#define MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW 0x2 -#define MLX5E_RX_MAX_HEAD (256) -#define MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ (64 * 1024)#define MLX5E_DEFAULT_LRO_TIMEOUT 32#define MLX5E_LRO_TIMEOUT_ARR_SIZE 4
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -2
@@ -171,8 +171,7 @@ static u8 mlx5e_mpwqe_get_log_stride_size(struct mlx5_core_dev *mdev,if (mlx5e_rx_mpwqe_is_linear_skb (mdev, params))return order_base_2 (mlx5e_rx_get_linear_frag_sz (params)); -return MLX5E_MPWQE_STRIDE_SZ (mdev, -MLX5E_GET_PFLAG (params,MLX5E_PFLAG_RX_CQE_COMPRESS )); +return MLX5_MPWRQ_DEF_LOG_STRIDE_SZ (mdev); } static u8 mlx5e_mpwqe_get_log_num_strides(struct mlx5_core_dev *mdev,
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -23
@@ -369,7 +369,7 @@ mlx5e_add_skb_frag(struct mlx5e_rq *rq, struct sk_buff *skb,static inline void mlx5e_copy_skb_header (struct device *pdev,struct sk_buff *skb,struct mlx5e_dma_info *dma_info, -int offset_from,int offset_to,u32 headlen) +int offset_from,u32 headlen) {const void *from =page_address (dma_info->page) + offset_from;/* Aligning len to sizeof(long) optimizes memcpy performance */
@@ -377,24 +377,7 @@ mlx5e_copy_skb_header(struct device *pdev, struct sk_buff *skb,dma_sync_single_for_cpu (pdev, dma_info->addr + offset_from, len,DMA_FROM_DEVICE ); -skb_copy_to_linear_data_offset (skb, offset_to, from, len); -} - -static inline void -mlx5e_copy_skb_header_mpwqe (struct device *pdev, -struct sk_buff *skb, -struct mlx5e_dma_info *dma_info, -u32 offset,u32 headlen) -{ -u16 headlen_pg =min_t (u32, headlen,PAGE_SIZE - offset); - -mlx5e_copy_skb_header (pdev, skb, dma_info, offset,0 , headlen_pg); - -if (unlikely (offset + headlen >PAGE_SIZE )) { - dma_info++; -mlx5e_copy_skb_header (pdev, skb, dma_info,0 , headlen_pg, - headlen - headlen_pg); - } +skb_copy_to_linear_data (skb, from, len); } static void
@@ -973,8 +956,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, }/* copy header */ -mlx5e_copy_skb_header (rq->pdev, skb, head_wi->di, head_wi->offset, -0 , headlen); +mlx5e_copy_skb_header (rq->pdev, skb, head_wi->di, head_wi->offset, headlen);/* skb linear part was allocated with headlen and aligned to long */ skb->tail += headlen; skb->len += headlen;
@@ -1096,8 +1078,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w di++; }/* copy header */ -mlx5e_copy_skb_header_mpwqe (rq->pdev, skb, head_di, - head_offset, headlen); +mlx5e_copy_skb_header (rq->pdev, skb, head_di, head_offset, headlen);/* skb linear part was allocated with headlen and aligned to long */ skb->tail += headlen; skb->len += headlen;
Signature · 1 line
2.20.1
PATCH 2/8 net/mlx5e: Take CQ decompress fields into a separate structure
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Only the Receive CQ makes use of these fields. Take them out into a separate struct and save space in the generic CQ structure.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 15 ++- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 127 ++++++++++-------- 2 files changed, 81 insertions(+), 61 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +9 -6
@@ -306,16 +306,18 @@ struct mlx5e_cq {struct mlx5_core_cq mcq;struct mlx5e_channel *channel; +/* control */ +struct mlx5_core_dev *mdev; +struct mlx5_wq_ctrl wq_ctrl; +}____cacheline_aligned_in_smp ; + +struct mlx5e_cq_decomp {/* cqe decompression */ struct mlx5_cqe64 title;struct mlx5_mini_cqe8 mini_arr[MLX5_MINI_CQE_ARRAY_SIZE ];u8 mini_arr_idx; -u16 decmprs_left; -u16 decmprs_wqe_counter; - -/* control */ -struct mlx5_core_dev *mdev; -struct mlx5_wq_ctrl wq_ctrl; +u16 left; +u16 wqe_counter; }____cacheline_aligned_in_smp ;struct mlx5e_tx_wqe_info {
@@ -578,6 +580,7 @@ struct mlx5e_rq {struct net_device *netdev;struct mlx5e_rq_stats *stats;struct mlx5e_cq cq; +struct mlx5e_cq_decomp cqd;struct mlx5e_page_cache page_cache;struct hwtstamp_config *tstamp;struct mlx5_clock *clock;
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +72 -55
224 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/8 net/mlx5e: Expand XPS cpumask to cover all online cpus
In reply to Saeed MahameedFrom: Moshe Shemesh <[email protected]>
Currently we have one cpu in XPS cpumask per tx queue, this is good enough for default configuration where there is a tx queue per cpu. However, once configuration changes to use less tx queues, part of the cpus are not XPS-mapped and so the select queue decision falls back to hash calculation and balancing is not guaranteed.
Expand XPS cpumask to enable using all cpus even when number of tx queues is smaller than number of cpus.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -638,6 +638,7 @@ struct mlx5e_channel {struct hwtstamp_config *tstamp;int ix;int cpu; +cpumask_var_t xps_cpumask; };struct mlx5e_channels {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +32 -2
@@ -1949,6 +1949,29 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)return err; } +static int mlx5e_alloc_xps_cpumask (struct mlx5e_channel *c, +struct mlx5e_params *params) +{ +int num_comp_vectors =mlx5_comp_vectors_count (c->mdev); +int irq; + +if (!zalloc_cpumask_var (&c->xps_cpumask,GFP_KERNEL )) +return -ENOMEM ; + +for (irq = c->ix; irq < num_comp_vectors; irq += params->num_channels) { +int cpu =cpumask_first (mlx5_comp_irq_get_affinity_mask (c->mdev, irq)); + +cpumask_set_cpu (cpu, c->xps_cpumask); + } + +return 0 ; +} + +static void mlx5e_free_xps_cpumask (struct mlx5e_channel *c) +{ +free_cpumask_var (c->xps_cpumask); +} + static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, struct mlx5e_params *params, struct mlx5e_channel_param *cparam,
@@ -1981,9 +2004,12 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, c->num_tc = params->num_tc; c->xdp = !!params->xdp_prog; c->stats = &priv->channel_stats[ix].ch; - c->irq_desc =irq_to_desc (irq); + err =mlx5e_alloc_xps_cpumask (c, params); +if (err) + goto err_free_channel; +netif_napi_add (netdev, &c->napi, mlx5e_napi_poll,64 ); err =mlx5e_open_cq (c, icocq_moder, &cparam->icosq_cq, &c->icosq.cq);
@@ -2066,6 +2092,9 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, err_napi_del:netif_napi_del (&c->napi); +mlx5e_free_xps_cpumask (c); + +err_free_channel:kvfree (c);return err;
@@ -2078,7 +2107,7 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)for (tc =0 ; tc < c->num_tc; tc++)mlx5e_activate_txqsq (&c->sq[tc]);mlx5e_activate_rq (&c->rq); -netif_set_xps_queue (c->netdev,get_cpu_mask (c->cpu), c->ix); +netif_set_xps_queue (c->netdev, c->xps_cpumask, c->ix); }static void mlx5e_deactivate_channel (struct mlx5e_channel *c)
@@ -2106,6 +2135,7 @@ static void mlx5e_close_channel(struct mlx5e_channel *c)mlx5e_close_tx_cqs (c);mlx5e_close_cq (&c->icosq.cq);netif_napi_del (&c->napi); +mlx5e_free_xps_cpumask (c);kvfree (c); }
Signature · 1 line
2.20.1
PATCH 4/8 net/mlx5e: Return the allocated flow directly from __mlx5e_add_fdb_flow
In reply to Saeed MahameedFrom: Jason Gunthorpe <[email protected]>
This confusing construction confuses the compiler which can't see that flow is initialized if !err:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function mlx5e_configure_flower drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:2727:28: warning:flow may be used uninitialized in this function [-Wmaybe-uninitialized]
There is no reason for two function outputs, just return the pointer directly and use ERR_PTR to encode a failure.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +14 -15
@@ -2767,14 +2767,13 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,return err; } -static int +static struct mlx5e_tc_flow *__mlx5e_add_fdb_flow (struct mlx5e_priv *priv,struct tc_cls_flower_offload *f,u16 flow_flags,struct net_device *filter_dev,struct mlx5_eswitch_rep *in_rep, -struct mlx5_core_dev *in_mdev, -struct mlx5e_tc_flow **__flow) +struct mlx5_core_dev *in_mdev) {struct netlink_ext_ack *extack = f->common.extack;struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -2814,15 +2813,13 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,if (err) goto err_free; - *__flow = flow; - -return 0 ; +return flow; err_free:kfree (flow);kvfree (parse_attr); out: -return err; +return ERR_PTR (err); } static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f,
@@ -2855,11 +2852,13 @@ static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f, in_mdev = priv->mdev; parse_attr = flow->esw_attr->parse_attr; - err =__mlx5e_add_fdb_flow (peer_priv, f, flow->flags, - parse_attr->filter_dev, - flow->esw_attr->in_rep, in_mdev, &peer_flow); -if (err) + peer_flow =__mlx5e_add_fdb_flow (peer_priv, f, flow->flags, + parse_attr->filter_dev, + flow->esw_attr->in_rep, in_mdev); +if (IS_ERR (peer_flow)) { + err =PTR_ERR (peer_flow); goto out; + } flow->peer_flow = peer_flow; flow->flags |=MLX5E_TC_FLOW_DUP ;
@@ -2885,10 +2884,10 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow;int err; - err =__mlx5e_add_fdb_flow (priv, f, flow_flags, filter_dev, in_rep, - in_mdev, &flow); -if (err) - goto out; + flow =__mlx5e_add_fdb_flow (priv, f, flow_flags, filter_dev, in_rep, + in_mdev); +if (IS_ERR (flow)) +return PTR_ERR (flow);if (is_peer_flow_needed (flow)) { err =mlx5e_tc_add_fdb_peer_flow (f, flow);
Signature · 1 line
2.20.1
PATCH 5/8 net/mlx5: Add trace points for flow tables create/destroy
In reply to Saeed MahameedFrom: Or Gerlitz <[email protected]>
We were not tracking flow tables so far, add it up.
--- .../mellanox/mlx5/core/diag/fs_tracepoint.c | 2 ++ .../mellanox/mlx5/core/diag/fs_tracepoint.h | 35 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/fs_core.c | 2 ++ 3 files changed, 39 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.c +2 -0
@@ -258,6 +258,8 @@ const char *parse_fs_dst(struct trace_seq *p,return ret; } +EXPORT_TRACEPOINT_SYMBOL (mlx5_fs_add_ft); +EXPORT_TRACEPOINT_SYMBOL (mlx5_fs_del_ft);EXPORT_TRACEPOINT_SYMBOL (mlx5_fs_add_fg);EXPORT_TRACEPOINT_SYMBOL (mlx5_fs_del_fg);EXPORT_TRACEPOINT_SYMBOL (mlx5_fs_set_fte);
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h +35 -0
@@ -61,6 +61,41 @@ const char *parse_fs_dst(struct trace_seq *p,const struct mlx5_flow_destination *dst, u32 counter_id); +TRACE_EVENT (mlx5_fs_add_ft, + TP_PROTO(const struct mlx5_flow_table *ft), +TP_ARGS (ft), +TP_STRUCT__entry ( + __field(const struct mlx5_flow_table *, ft) + __field(u32, id) + __field(u32, level) +__field (u32, type) + ), +TP_fast_assign ( + __entry->ft = ft; + __entry->id = ft->id; + __entry->level = ft->level; + __entry->type = ft->type; + ), +TP_printk ("ft=%p id=%u level=%u type=%u \n" , + __entry->ft, __entry->id, __entry->level, __entry->type) + ); + +TRACE_EVENT (mlx5_fs_del_ft, + TP_PROTO(const struct mlx5_flow_table *ft), +TP_ARGS (ft), +TP_STRUCT__entry ( + __field(const struct mlx5_flow_table *, ft) +__field (u32, id) + ), +TP_fast_assign ( + __entry->ft = ft; + __entry->id = ft->id; + + ), +TP_printk ("ft=%p id=%u\n" , + __entry->ft, __entry->id) + ); + TRACE_EVENT(mlx5_fs_add_fg, TP_PROTO(const struct mlx5_flow_group *fg), TP_ARGS(fg),
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +2 -0
@@ -397,6 +397,7 @@ static void del_hw_flow_table(struct fs_node *node)fs_get_obj (ft, node); dev =get_dev (&ft->node); root =find_root (&ft->node); +trace_mlx5_fs_del_ft (ft);if (node->active) { err = root->cmds->destroy_flow_table (dev, ft);
@@ -1019,6 +1020,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa fs_prio->num_ft++;up_write_ref_node (&fs_prio->node);mutex_unlock (&root->chain_lock); +trace_mlx5_fs_add_ft (ft);return ft; destroy_ft: root->cmds->destroy_flow_table (root->dev, ft);
Signature · 1 line
2.20.1
PATCH 6/8 net/mlx5e: Separate between ethtool and netdev software stats folding
In reply to Saeed Mahameedmlx5e_grp_sw_update_stats can be called from two threads,
1) ndo_get_stats64
2) get_ethtool_stats
For this reason and to minimize concurrency issue impact on 64bit machines mlx5e_grp_sw_update_stats folds the software stats into a temporary variable then copies it to the global driver stats, both ethtool and ndo statistics callbacks will use the global software stats variable to report whatever stats they need.
Actually ndo_get_stats64 doesn't need to fold the whole software stats (mlx5e_grp_sw_update_stats), all it needs is five counters to fill the rtnl_link_stats64 relevant stats parameter.
Hence this patch introduces a simpler helper function to fold software stats for ndo_get_stats64 which will work directly on rtnl_link_stats64 stats parameter and not on the global or even temporary mlx5e_sw_stats variable.
Since now mlx5e_grp_sw_update_stats is not called by ndo_get_stats64 we can make it static and remove the temp var.
Unlike mlx5e_grp_sw_update_stats the new fold stats function doesn't need to zero out the output statistics parameter since it is already done by the stack @dev_get_stats().
This patch is fixing stack usage of mlx5e_grp_sw_update_stats on x86 gcc-4.9 and higher, the concurrency issue between mlx5's ndo_get_stats64 and get_ethtool_stats is resolved as well.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 30 ++++++++++++++----- .../ethernet/mellanox/mlx5/core/en_stats.c | 6 ++-- .../ethernet/mellanox/mlx5/core/en_stats.h | 1 - 3 files changed, 25 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +23 -7
@@ -3521,11 +3521,32 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, } } +static void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s) +{ +int i; + +for (i =0 ; i <mlx5e_get_netdev_max_channels (priv->netdev); i++) { +struct mlx5e_channel_stats *channel_stats = &priv->channel_stats[i]; +struct mlx5e_rq_stats *rq_stats = &channel_stats->rq; +int j; + + s->rx_packets += rq_stats->packets; + s->rx_bytes += rq_stats->bytes; + +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; + } + } +} +void mlx5e_get_stats (struct net_device *dev,struct rtnl_link_stats64 *stats) {struct mlx5e_priv *priv =netdev_priv (dev); -struct mlx5e_sw_stats *sstats = &priv->stats.sw;struct mlx5e_vport_stats *vstats = &priv->stats.vport;struct mlx5e_pport_stats *pstats = &priv->stats.pport;
@@ -3540,12 +3561,7 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) stats->tx_packets =PPORT_802_3_GET (pstats, a_frames_transmitted_ok); stats->tx_bytes =PPORT_802_3_GET (pstats, a_octets_transmitted_ok); }else { -mlx5e_grp_sw_update_stats (priv); - stats->rx_packets = sstats->rx_packets; - stats->rx_bytes = sstats->rx_bytes; - stats->tx_packets = sstats->tx_packets; - stats->tx_bytes = sstats->tx_bytes; - stats->tx_dropped = sstats->tx_queue_dropped; +mlx5e_fold_sw_stats64 (priv, stats); } stats->rx_dropped = priv->stats.qcnt.rx_out_of_buffer;
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +2 -4
@@ -127,9 +127,9 @@ static int mlx5e_grp_sw_fill_stats(struct mlx5e_priv *priv, u64 *data, int idx)return idx; } -void mlx5e_grp_sw_update_stats (struct mlx5e_priv *priv) +static void mlx5e_grp_sw_update_stats (struct mlx5e_priv *priv) { -struct mlx5e_sw_stats temp, *s = &temp; +struct mlx5e_sw_stats *s = &priv->stats.sw;int i;memset (s,0 ,sizeof (*s));
@@ -212,8 +212,6 @@ void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv) s->tx_cqes += sq_stats->cqes; } } - -memcpy (&priv->stats.sw, s,sizeof (*s)); }static const struct counter_desc q_stats_desc[] = {
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +0 -1
@@ -277,7 +277,6 @@ struct mlx5e_stats_grp {extern const struct mlx5e_stats_grp mlx5e_stats_grps[];extern const int mlx5e_num_stats_grps; -void mlx5e_grp_sw_update_stats (struct mlx5e_priv *priv);void mlx5e_grp_802_3_update_stats (struct mlx5e_priv *priv);#endif /* __MLX5_EN_STATS_H__ */
Signature · 1 line
2.20.1
PATCH 7/8 net/mlx5e: Present the representors SW stats when state is not opened
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
This behavior is already adopted for all other cases in the cited patch. The representor's functions were missed, here we modify the them to behave similarly.
--- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +7 -10
@@ -162,21 +162,19 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)static void mlx5e_rep_update_sw_counters (struct mlx5e_priv *priv) {struct mlx5e_sw_stats *s = &priv->stats.sw; -struct mlx5e_rq_stats *rq_stats; -struct mlx5e_sq_stats *sq_stats;int i, j;memset (s,0 ,sizeof (*s)); -for (i =0 ; i < priv->channels.num; i++) { -struct mlx5e_channel *c = priv->channels.c[i]; - - rq_stats = c->rq.stats; +for (i =0 ; i <mlx5e_get_netdev_max_channels (priv->netdev); i++) { +struct mlx5e_channel_stats *channel_stats = + &priv->channel_stats[i]; +struct mlx5e_rq_stats *rq_stats = &channel_stats->rq; s->rx_packets += rq_stats->packets; s->rx_bytes += rq_stats->bytes; -for (j =0 ; j < priv->channels.params.num_tc; j++) { - sq_stats = c->sq[j].stats; +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;
@@ -195,8 +193,7 @@ static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,return ;mutex_lock (&priv->state_lock); -if (test_bit (MLX5E_STATE_OPENED , &priv->state)) -mlx5e_rep_update_sw_counters (priv); +mlx5e_rep_update_sw_counters (priv);mlx5e_rep_update_hw_counters (priv);mutex_unlock (&priv->state_lock);
Signature · 1 line
2.20.1
PATCH 8/8 net/mlx5e: Reuse fold sw stats in representors
In reply to Saeed MahameedRepresentors software stats are basic, this patch is reusing the mlx5e_fold_sw_stats in representors, which sums up the basic stats64 for a mlx5e netdevice.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 34 +++++-------------- 3 files changed, 10 insertions(+), 27 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -804,6 +804,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,void mlx5e_update_stats (struct mlx5e_priv *priv);void mlx5e_get_stats (struct net_device *dev,struct rtnl_link_stats64 *stats); +void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s);void mlx5e_init_l2_addr (struct mlx5e_priv *priv);int mlx5e_self_test_num (struct mlx5e_priv *priv);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -3521,7 +3521,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, } } -static void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s) +void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s) {int i;
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +8 -26
@@ -162,25 +162,16 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)static void mlx5e_rep_update_sw_counters (struct mlx5e_priv *priv) {struct mlx5e_sw_stats *s = &priv->stats.sw; -int i, j; +struct rtnl_link_stats64 stats64 = {};memset (s,0 ,sizeof (*s)); -for (i =0 ; i <mlx5e_get_netdev_max_channels (priv->netdev); i++) { -struct mlx5e_channel_stats *channel_stats = - &priv->channel_stats[i]; -struct mlx5e_rq_stats *rq_stats = &channel_stats->rq; - - s->rx_packets += rq_stats->packets; - s->rx_bytes += rq_stats->bytes; - -for (j =0 ; j < priv->max_opened_tc; j++) { -struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j]; +mlx5e_fold_sw_stats64 (priv, &stats64); - s->tx_packets += sq_stats->packets; - s->tx_bytes += sq_stats->bytes; - s->tx_queue_dropped += sq_stats->dropped; - } - } + s->rx_packets = stats64.rx_packets; + s->rx_bytes = stats64.rx_bytes; + s->tx_packets = stats64.tx_packets; + s->tx_bytes = stats64.tx_bytes; + s->tx_queue_dropped = stats64.tx_dropped; } static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
@@ -1226,17 +1217,8 @@ mlx5e_get_sw_stats64(const struct net_device *dev, struct rtnl_link_stats64 *stats) {struct mlx5e_priv *priv =netdev_priv (dev); -struct mlx5e_sw_stats *sstats = &priv->stats.sw; - -mlx5e_rep_update_sw_counters (priv); - - stats->rx_packets = sstats->rx_packets; - stats->rx_bytes = sstats->rx_bytes; - stats->tx_packets = sstats->tx_packets; - stats->tx_bytes = sstats->tx_bytes; - - stats->tx_dropped = sstats->tx_queue_dropped; +mlx5e_fold_sw_stats64 (priv, stats);return 0 ; }
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Fri, 25 Jan 2019 12:18:10 -0800
Quoted 4 lines
This series provides some misc updates to mlx5 driver. For more information please see tag log below.
Please pull and let me know if there is any problem.
Pulled, thanks.