aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-06-11 16:40:52 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-11 16:40:52 -0400
commit062bb997d290879ea711d149189daf485bd777b3 (patch)
tree5fb23e03289481ab46036ff623b93ac7e8dc5473
parent77a6bb5ac00dd48934dae0df4a24461cc7893d64 (diff)
parent91828bd89940e8145f91751a015bc11bc486aad0 (diff)
Merge tag 'mlx5-fixes-2017-06-11' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== Mellanox mlx5 fixes 2017-06-11 This series contains some fixes for the mlx5 core and netdev driver. Please pull and let me know if there's any problem. For -stable: ("net/mlx5e: Added BW check for DIM decision mechanism") kernels >= 4.9 ("net/mlx5e: Fix wrong indications in DIM due to counter wraparound") kernels >= 4.9 ("net/mlx5: Remove several module events out of ethtool stats") kernels >= 4.10 ("net/mlx5: Enable 4K UAR only when page size is bigger than 4K") kernels >= 4.11 *all patches apply with no issue on their -stable. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c45
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c6
6 files changed, 43 insertions, 40 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 2fd044b23875..944fc1742464 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -458,13 +458,15 @@ struct mlx5e_mpw_info {
458 458
459struct mlx5e_rx_am_stats { 459struct mlx5e_rx_am_stats {
460 int ppms; /* packets per msec */ 460 int ppms; /* packets per msec */
461 int bpms; /* bytes per msec */
461 int epms; /* events per msec */ 462 int epms; /* events per msec */
462}; 463};
463 464
464struct mlx5e_rx_am_sample { 465struct mlx5e_rx_am_sample {
465 ktime_t time; 466 ktime_t time;
466 unsigned int pkt_ctr; 467 u32 pkt_ctr;
467 u16 event_ctr; 468 u32 byte_ctr;
469 u16 event_ctr;
468}; 470};
469 471
470struct mlx5e_rx_am { /* Adaptive Moderation */ 472struct mlx5e_rx_am { /* Adaptive Moderation */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
index 02dd3a95ed8f..acf32fe952cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c
@@ -183,28 +183,27 @@ static void mlx5e_am_exit_parking(struct mlx5e_rx_am *am)
183 mlx5e_am_step(am); 183 mlx5e_am_step(am);
184} 184}
185 185
186#define IS_SIGNIFICANT_DIFF(val, ref) \
187 (((100 * abs((val) - (ref))) / (ref)) > 10) /* more than 10% difference */
188
186static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, 189static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr,
187 struct mlx5e_rx_am_stats *prev) 190 struct mlx5e_rx_am_stats *prev)
188{ 191{
189 int diff; 192 if (!prev->bpms)
190 193 return curr->bpms ? MLX5E_AM_STATS_BETTER :
191 if (!prev->ppms)
192 return curr->ppms ? MLX5E_AM_STATS_BETTER :
193 MLX5E_AM_STATS_SAME; 194 MLX5E_AM_STATS_SAME;
194 195
195 diff = curr->ppms - prev->ppms; 196 if (IS_SIGNIFICANT_DIFF(curr->bpms, prev->bpms))
196 if (((100 * abs(diff)) / prev->ppms) > 10) /* more than 10% diff */ 197 return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER :
197 return (diff > 0) ? MLX5E_AM_STATS_BETTER : 198 MLX5E_AM_STATS_WORSE;
198 MLX5E_AM_STATS_WORSE;
199 199
200 if (!prev->epms) 200 if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms))
201 return curr->epms ? MLX5E_AM_STATS_WORSE : 201 return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER :
202 MLX5E_AM_STATS_SAME; 202 MLX5E_AM_STATS_WORSE;
203 203
204 diff = curr->epms - prev->epms; 204 if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms))
205 if (((100 * abs(diff)) / prev->epms) > 10) /* more than 10% diff */ 205 return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER :
206 return (diff < 0) ? MLX5E_AM_STATS_BETTER : 206 MLX5E_AM_STATS_WORSE;
207 MLX5E_AM_STATS_WORSE;
208 207
209 return MLX5E_AM_STATS_SAME; 208 return MLX5E_AM_STATS_SAME;
210} 209}
@@ -266,10 +265,13 @@ static void mlx5e_am_sample(struct mlx5e_rq *rq,
266{ 265{
267 s->time = ktime_get(); 266 s->time = ktime_get();
268 s->pkt_ctr = rq->stats.packets; 267 s->pkt_ctr = rq->stats.packets;
268 s->byte_ctr = rq->stats.bytes;
269 s->event_ctr = rq->cq.event_ctr; 269 s->event_ctr = rq->cq.event_ctr;
270} 270}
271 271
272#define MLX5E_AM_NEVENTS 64 272#define MLX5E_AM_NEVENTS 64
273#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
274#define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1))
273 275
274static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start, 276static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
275 struct mlx5e_rx_am_sample *end, 277 struct mlx5e_rx_am_sample *end,
@@ -277,13 +279,17 @@ static void mlx5e_am_calc_stats(struct mlx5e_rx_am_sample *start,
277{ 279{
278 /* u32 holds up to 71 minutes, should be enough */ 280 /* u32 holds up to 71 minutes, should be enough */
279 u32 delta_us = ktime_us_delta(end->time, start->time); 281 u32 delta_us = ktime_us_delta(end->time, start->time);
280 unsigned int npkts = end->pkt_ctr - start->pkt_ctr; 282 u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
283 u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
284 start->byte_ctr);
281 285
282 if (!delta_us) 286 if (!delta_us)
283 return; 287 return;
284 288
285 curr_stats->ppms = (npkts * USEC_PER_MSEC) / delta_us; 289 curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us);
286 curr_stats->epms = (MLX5E_AM_NEVENTS * USEC_PER_MSEC) / delta_us; 290 curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
291 curr_stats->epms = DIV_ROUND_UP(MLX5E_AM_NEVENTS * USEC_PER_MSEC,
292 delta_us);
287} 293}
288 294
289void mlx5e_rx_am_work(struct work_struct *work) 295void mlx5e_rx_am_work(struct work_struct *work)
@@ -308,7 +314,8 @@ void mlx5e_rx_am(struct mlx5e_rq *rq)
308 314
309 switch (am->state) { 315 switch (am->state) {
310 case MLX5E_AM_MEASURE_IN_PROGRESS: 316 case MLX5E_AM_MEASURE_IN_PROGRESS:
311 nevents = rq->cq.event_ctr - am->start_sample.event_ctr; 317 nevents = BIT_GAP(BITS_PER_TYPE(u16), rq->cq.event_ctr,
318 am->start_sample.event_ctr);
312 if (nevents < MLX5E_AM_NEVENTS) 319 if (nevents < MLX5E_AM_NEVENTS)
313 break; 320 break;
314 mlx5e_am_sample(rq, &end_sample); 321 mlx5e_am_sample(rq, &end_sample);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 53e4992d6511..f81c3aa60b46 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -417,20 +417,13 @@ struct mlx5e_stats {
417}; 417};
418 418
419static const struct counter_desc mlx5e_pme_status_desc[] = { 419static const struct counter_desc mlx5e_pme_status_desc[] = {
420 { "module_plug", 0 },
421 { "module_unplug", 8 }, 420 { "module_unplug", 8 },
422}; 421};
423 422
424static const struct counter_desc mlx5e_pme_error_desc[] = { 423static const struct counter_desc mlx5e_pme_error_desc[] = {
425 { "module_pwr_budget_exd", 0 }, /* power budget exceed */ 424 { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */
426 { "module_long_range", 8 }, /* long range for non MLNX cable */ 425 { "module_high_temp", 48 }, /* high temperature */
427 { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */
428 { "module_no_eeprom", 24 }, /* no eeprom/retry time out */
429 { "module_enforce_part", 32 }, /* enforce part number list */
430 { "module_unknown_id", 40 }, /* unknown identifier */
431 { "module_high_temp", 48 }, /* high temperature */
432 { "module_bad_shorted", 56 }, /* bad or shorted cable/module */ 426 { "module_bad_shorted", 56 }, /* bad or shorted cable/module */
433 { "module_unknown_status", 64 },
434}; 427};
435 428
436#endif /* __MLX5_EN_STATS_H__ */ 429#endif /* __MLX5_EN_STATS_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 0e487e8ca634..8f5125ccd8d4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -862,7 +862,7 @@ struct mlx5_flow_table *mlx5_create_vport_flow_table(struct mlx5_flow_namespace
862 ft_attr.level = level; 862 ft_attr.level = level;
863 ft_attr.prio = prio; 863 ft_attr.prio = prio;
864 864
865 return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, 0); 865 return __mlx5_create_flow_table(ns, &ft_attr, FS_FT_OP_MOD_NORMAL, vport);
866} 866}
867 867
868struct mlx5_flow_table* 868struct mlx5_flow_table*
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 44f59b1d6f0f..f27f84ffbc85 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -275,10 +275,8 @@ static void poll_health(unsigned long data)
275 struct mlx5_core_health *health = &dev->priv.health; 275 struct mlx5_core_health *health = &dev->priv.health;
276 u32 count; 276 u32 count;
277 277
278 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 278 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
279 mod_timer(&health->timer, get_next_poll_jiffies()); 279 goto out;
280 return;
281 }
282 280
283 count = ioread32be(health->health_counter); 281 count = ioread32be(health->health_counter);
284 if (count == health->prev) 282 if (count == health->prev)
@@ -290,8 +288,6 @@ static void poll_health(unsigned long data)
290 if (health->miss_counter == MAX_MISSES) { 288 if (health->miss_counter == MAX_MISSES) {
291 dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n"); 289 dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n");
292 print_health_info(dev); 290 print_health_info(dev);
293 } else {
294 mod_timer(&health->timer, get_next_poll_jiffies());
295 } 291 }
296 292
297 if (in_fatal(dev) && !health->sick) { 293 if (in_fatal(dev) && !health->sick) {
@@ -305,6 +301,9 @@ static void poll_health(unsigned long data)
305 "new health works are not permitted at this stage\n"); 301 "new health works are not permitted at this stage\n");
306 spin_unlock(&health->wq_lock); 302 spin_unlock(&health->wq_lock);
307 } 303 }
304
305out:
306 mod_timer(&health->timer, get_next_poll_jiffies());
308} 307}
309 308
310void mlx5_start_health_poll(struct mlx5_core_dev *dev) 309void mlx5_start_health_poll(struct mlx5_core_dev *dev)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index af945edfee19..4f577a5abf88 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -537,8 +537,10 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
537 /* disable cmdif checksum */ 537 /* disable cmdif checksum */
538 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0); 538 MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0);
539 539
540 /* If the HCA supports 4K UARs use it */ 540 /* Enable 4K UAR only when HCA supports it and page size is bigger
541 if (MLX5_CAP_GEN_MAX(dev, uar_4k)) 541 * than 4K.
542 */
543 if (MLX5_CAP_GEN_MAX(dev, uar_4k) && PAGE_SIZE > 4096)
542 MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1); 544 MLX5_SET(cmd_hca_cap, set_hca_cap, uar_4k, 1);
543 545
544 MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12); 546 MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);