Imported Upstream version 16.07-rc1
[deb_dpdk.git] / drivers / net / mlx5 / mlx5_prm.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright 2016 6WIND S.A.
5  *   Copyright 2016 Mellanox.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of 6WIND S.A. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef RTE_PMD_MLX5_PRM_H_
35 #define RTE_PMD_MLX5_PRM_H_
36
37 /* Verbs header. */
38 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
39 #ifdef PEDANTIC
40 #pragma GCC diagnostic ignored "-pedantic"
41 #endif
42 #include <infiniband/mlx5_hw.h>
43 #ifdef PEDANTIC
44 #pragma GCC diagnostic error "-pedantic"
45 #endif
46
47 /* Get CQE owner bit. */
48 #define MLX5_CQE_OWNER(op_own) ((op_own) & MLX5_CQE_OWNER_MASK)
49
50 /* Get CQE format. */
51 #define MLX5_CQE_FORMAT(op_own) (((op_own) & MLX5E_CQE_FORMAT_MASK) >> 2)
52
53 /* Get CQE opcode. */
54 #define MLX5_CQE_OPCODE(op_own) (((op_own) & 0xf0) >> 4)
55
56 /* Get CQE solicited event. */
57 #define MLX5_CQE_SE(op_own) (((op_own) >> 1) & 1)
58
59 /* Invalidate a CQE. */
60 #define MLX5_CQE_INVALIDATE (MLX5_CQE_INVALID << 4)
61
62 /* CQE value to inform that VLAN is stripped. */
63 #define MLX5_CQE_VLAN_STRIPPED 0x1
64
65 /* Maximum number of packets a multi-packet WQE can handle. */
66 #define MLX5_MPW_DSEG_MAX 5
67
68 /* Room for inline data in regular work queue element. */
69 #define MLX5_WQE64_INL_DATA 12
70
71 /* Room for inline data in multi-packet WQE. */
72 #define MLX5_MWQE64_INL_DATA 28
73
74 /* Subset of struct mlx5_wqe_eth_seg. */
75 struct mlx5_wqe_eth_seg_small {
76         uint32_t rsvd0;
77         uint8_t cs_flags;
78         uint8_t rsvd1;
79         uint16_t mss;
80         uint32_t rsvd2;
81         uint16_t inline_hdr_sz;
82 };
83
84 /* Regular WQE. */
85 struct mlx5_wqe_regular {
86         union {
87                 struct mlx5_wqe_ctrl_seg ctrl;
88                 uint32_t data[4];
89         } ctrl;
90         struct mlx5_wqe_eth_seg eseg;
91         struct mlx5_wqe_data_seg dseg;
92 } __rte_aligned(64);
93
94 /* Inline WQE. */
95 struct mlx5_wqe_inl {
96         union {
97                 struct mlx5_wqe_ctrl_seg ctrl;
98                 uint32_t data[4];
99         } ctrl;
100         struct mlx5_wqe_eth_seg eseg;
101         uint32_t byte_cnt;
102         uint8_t data[MLX5_WQE64_INL_DATA];
103 } __rte_aligned(64);
104
105 /* Multi-packet WQE. */
106 struct mlx5_wqe_mpw {
107         union {
108                 struct mlx5_wqe_ctrl_seg ctrl;
109                 uint32_t data[4];
110         } ctrl;
111         struct mlx5_wqe_eth_seg_small eseg;
112         struct mlx5_wqe_data_seg dseg[2];
113 } __rte_aligned(64);
114
115 /* Multi-packet WQE with inline. */
116 struct mlx5_wqe_mpw_inl {
117         union {
118                 struct mlx5_wqe_ctrl_seg ctrl;
119                 uint32_t data[4];
120         } ctrl;
121         struct mlx5_wqe_eth_seg_small eseg;
122         uint32_t byte_cnt;
123         uint8_t data[MLX5_MWQE64_INL_DATA];
124 } __rte_aligned(64);
125
126 /* Union of all WQE types. */
127 union mlx5_wqe {
128         struct mlx5_wqe_regular wqe;
129         struct mlx5_wqe_inl inl;
130         struct mlx5_wqe_mpw mpw;
131         struct mlx5_wqe_mpw_inl mpw_inl;
132         uint8_t data[64];
133 };
134
135 /* MPW session status. */
136 enum mlx5_mpw_state {
137         MLX5_MPW_STATE_OPENED,
138         MLX5_MPW_INL_STATE_OPENED,
139         MLX5_MPW_STATE_CLOSED,
140 };
141
142 /* MPW session descriptor. */
143 struct mlx5_mpw {
144         enum mlx5_mpw_state state;
145         unsigned int pkts_n;
146         unsigned int len;
147         unsigned int total_len;
148         volatile union mlx5_wqe *wqe;
149         union {
150                 volatile struct mlx5_wqe_data_seg *dseg[MLX5_MPW_DSEG_MAX];
151                 volatile uint8_t *raw;
152         } data;
153 };
154
155 /* CQ element structure - should be equal to the cache line size */
156 struct mlx5_cqe {
157 #if (RTE_CACHE_LINE_SIZE == 128)
158         uint8_t padding[64];
159 #endif
160         struct mlx5_cqe64 cqe64;
161 };
162
163 #endif /* RTE_PMD_MLX5_PRM_H_ */