1dc7e38acSHans Petter Selasky /*-
2dc7e38acSHans Petter Selasky * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
3dc7e38acSHans Petter Selasky *
4dc7e38acSHans Petter Selasky * Redistribution and use in source and binary forms, with or without
5dc7e38acSHans Petter Selasky * modification, are permitted provided that the following conditions
6dc7e38acSHans Petter Selasky * are met:
7dc7e38acSHans Petter Selasky * 1. Redistributions of source code must retain the above copyright
8dc7e38acSHans Petter Selasky * notice, this list of conditions and the following disclaimer.
9dc7e38acSHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright
10dc7e38acSHans Petter Selasky * notice, this list of conditions and the following disclaimer in the
11dc7e38acSHans Petter Selasky * documentation and/or other materials provided with the distribution.
12dc7e38acSHans Petter Selasky *
13dc7e38acSHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14dc7e38acSHans Petter Selasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15dc7e38acSHans Petter Selasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16dc7e38acSHans Petter Selasky * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17dc7e38acSHans Petter Selasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18dc7e38acSHans Petter Selasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19dc7e38acSHans Petter Selasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20dc7e38acSHans Petter Selasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21dc7e38acSHans Petter Selasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22dc7e38acSHans Petter Selasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23dc7e38acSHans Petter Selasky * SUCH DAMAGE.
24dc7e38acSHans Petter Selasky */
25dc7e38acSHans Petter Selasky
26b984b956SKonstantin Belousov #include "opt_rss.h"
27b984b956SKonstantin Belousov #include "opt_ratelimit.h"
28b984b956SKonstantin Belousov
29*bc531a1fSHans Petter Selasky #include <linux/printk.h>
30*bc531a1fSHans Petter Selasky
3189918a23SKonstantin Belousov #include <dev/mlx5/mlx5_en/en.h>
32dc7e38acSHans Petter Selasky
33dc7e38acSHans Petter Selasky struct mlx5_cqe64 *
mlx5e_get_cqe(struct mlx5e_cq * cq)34dc7e38acSHans Petter Selasky mlx5e_get_cqe(struct mlx5e_cq *cq)
35dc7e38acSHans Petter Selasky {
36dc7e38acSHans Petter Selasky struct mlx5_cqe64 *cqe;
37dc7e38acSHans Petter Selasky
38dc7e38acSHans Petter Selasky cqe = mlx5_cqwq_get_wqe(&cq->wq, mlx5_cqwq_get_ci(&cq->wq));
39dc7e38acSHans Petter Selasky
40dc7e38acSHans Petter Selasky if ((cqe->op_own ^ mlx5_cqwq_get_wrap_cnt(&cq->wq)) & MLX5_CQE_OWNER_MASK)
41dc7e38acSHans Petter Selasky return (NULL);
42dc7e38acSHans Petter Selasky
43dc7e38acSHans Petter Selasky /* ensure cqe content is read after cqe ownership bit */
449cb83c46SHans Petter Selasky atomic_thread_fence_acq();
45dc7e38acSHans Petter Selasky
46dc7e38acSHans Petter Selasky return (cqe);
47dc7e38acSHans Petter Selasky }
48dc7e38acSHans Petter Selasky
49dc7e38acSHans Petter Selasky void
mlx5e_cq_error_event(struct mlx5_core_cq * mcq,int event)50dc7e38acSHans Petter Selasky mlx5e_cq_error_event(struct mlx5_core_cq *mcq, int event)
51dc7e38acSHans Petter Selasky {
52dc7e38acSHans Petter Selasky struct mlx5e_cq *cq = container_of(mcq, struct mlx5e_cq, mcq);
53dc7e38acSHans Petter Selasky
546b4040d8SHans Petter Selasky mlx5_en_err(cq->priv->ifp, "cqn=0x%.6x event=0x%.2x\n",
556b4040d8SHans Petter Selasky mcq->cqn, event);
56dc7e38acSHans Petter Selasky }
57*bc531a1fSHans Petter Selasky
58*bc531a1fSHans Petter Selasky void
mlx5e_dump_err_cqe(struct mlx5e_cq * cq,u32 qn,const struct mlx5_err_cqe * err_cqe)59*bc531a1fSHans Petter Selasky mlx5e_dump_err_cqe(struct mlx5e_cq *cq, u32 qn, const struct mlx5_err_cqe *err_cqe)
60*bc531a1fSHans Petter Selasky {
61*bc531a1fSHans Petter Selasky u32 ci;
62*bc531a1fSHans Petter Selasky
63*bc531a1fSHans Petter Selasky /* Don't print flushed in error syndromes. */
64*bc531a1fSHans Petter Selasky if (err_cqe->vendor_err_synd == 0xf9 && err_cqe->syndrome == 0x05)
65*bc531a1fSHans Petter Selasky return;
66*bc531a1fSHans Petter Selasky /* Don't print when the queue is set to error state by software. */
67*bc531a1fSHans Petter Selasky if (err_cqe->vendor_err_synd == 0xf5 && err_cqe->syndrome == 0x05)
68*bc531a1fSHans Petter Selasky return;
69*bc531a1fSHans Petter Selasky
70*bc531a1fSHans Petter Selasky ci = (cq->wq.cc - 1) & cq->wq.sz_m1;
71*bc531a1fSHans Petter Selasky
72*bc531a1fSHans Petter Selasky mlx5_en_err(cq->priv->ifp,
73*bc531a1fSHans Petter Selasky "Error CQE on CQN 0x%x, CI 0x%x, QN 0x%x, OPCODE 0x%x, SYNDROME 0x%x, VENDOR SYNDROME 0x%x\n",
74*bc531a1fSHans Petter Selasky cq->mcq.cqn, ci, qn, err_cqe->op_own >> 4,
75*bc531a1fSHans Petter Selasky err_cqe->syndrome, err_cqe->vendor_err_synd);
76*bc531a1fSHans Petter Selasky
77*bc531a1fSHans Petter Selasky print_hex_dump(NULL, NULL, DUMP_PREFIX_OFFSET,
78*bc531a1fSHans Petter Selasky 16, 1, err_cqe, sizeof(*err_cqe), false);
79*bc531a1fSHans Petter Selasky }
80