1290650Shselasky/*-
2290650Shselasky * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
3290650Shselasky *
4290650Shselasky * Redistribution and use in source and binary forms, with or without
5290650Shselasky * modification, are permitted provided that the following conditions
6290650Shselasky * are met:
7290650Shselasky * 1. Redistributions of source code must retain the above copyright
8290650Shselasky *    notice, this list of conditions and the following disclaimer.
9290650Shselasky * 2. Redistributions in binary form must reproduce the above copyright
10290650Shselasky *    notice, this list of conditions and the following disclaimer in the
11290650Shselasky *    documentation and/or other materials provided with the distribution.
12290650Shselasky *
13290650Shselasky * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14290650Shselasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15290650Shselasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16290650Shselasky * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17290650Shselasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18290650Shselasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19290650Shselasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20290650Shselasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21290650Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22290650Shselasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23290650Shselasky * SUCH DAMAGE.
24290650Shselasky *
25290650Shselasky * $FreeBSD: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_txrx.c 353226 2019-10-07 09:28:53Z hselasky $
26290650Shselasky */
27290650Shselasky
28290650Shselasky#include "en.h"
29290650Shselasky
30290650Shselaskystruct mlx5_cqe64 *
31290650Shselaskymlx5e_get_cqe(struct mlx5e_cq *cq)
32290650Shselasky{
33290650Shselasky	struct mlx5_cqe64 *cqe;
34290650Shselasky
35290650Shselasky	cqe = mlx5_cqwq_get_wqe(&cq->wq, mlx5_cqwq_get_ci(&cq->wq));
36290650Shselasky
37290650Shselasky	if ((cqe->op_own ^ mlx5_cqwq_get_wrap_cnt(&cq->wq)) & MLX5_CQE_OWNER_MASK)
38290650Shselasky		return (NULL);
39290650Shselasky
40290650Shselasky	/* ensure cqe content is read after cqe ownership bit */
41331590Shselasky	atomic_thread_fence_acq();
42290650Shselasky
43290650Shselasky	return (cqe);
44290650Shselasky}
45290650Shselasky
46290650Shselaskyvoid
47290650Shselaskymlx5e_cq_error_event(struct mlx5_core_cq *mcq, int event)
48290650Shselasky{
49290650Shselasky	struct mlx5e_cq *cq = container_of(mcq, struct mlx5e_cq, mcq);
50290650Shselasky
51353226Shselasky	mlx5_en_err(cq->priv->ifp, "cqn=0x%.6x event=0x%.2x\n",
52353226Shselasky	    mcq->cqn, event);
53290650Shselasky}
54