szedata2: add new poll mode driver
[dpdk.git] / drivers / net / szedata2 / rte_eth_szedata2.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2015 CESNET
5  *   All rights reserved.
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 CESNET 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_SZEDATA2_H_
35 #define RTE_PMD_SZEDATA2_H_
36
37 /* szedata2_packet header length == 4 bytes == 2B segment size + 2B hw size */
38 #define RTE_SZE2_PACKET_HEADER_SIZE 4
39
40 #define RTE_SZE2_MMIO_MAX 10
41
42 /*!
43  * Round 'what' to the nearest larger (or equal) multiple of '8'
44  * (szedata2 packet is aligned to 8 bytes)
45  */
46 #define RTE_SZE2_ALIGN8(what) (((what) + ((8) - 1)) & (~((8) - 1)))
47
48 /*! main handle structure */
49 struct szedata {
50         int fd;
51         struct sze2_instance_info *info;
52         uint32_t *write_size;
53         void *space[RTE_SZE2_MMIO_MAX];
54         struct szedata_lock lock[2][2];
55
56         __u32 *rx_asize, *tx_asize;
57
58         /* szedata_read_next variables - to keep context (ct) */
59
60         /*
61          * rx
62          */
63         /** initial sze lock ptr */
64         const struct szedata_lock   *ct_rx_lck_orig;
65         /** current sze lock ptr (initial or next) */
66         const struct szedata_lock   *ct_rx_lck;
67         /** remaining bytes (not read) within current lock */
68         unsigned int                ct_rx_rem_bytes;
69         /** current pointer to locked memory */
70         unsigned char               *ct_rx_cur_ptr;
71         /**
72          * allocated buffer to store RX packet if it was split
73          * into 2 buffers
74          */
75         unsigned char               *ct_rx_buffer;
76         /** registered function to provide filtering based on hwdata */
77         int (*ct_rx_filter)(u_int16_t hwdata_len, u_char *hwdata);
78
79         /*
80          * tx
81          */
82         /**
83          * buffer for tx - packet is prepared here
84          * (in future for burst write)
85          */
86         unsigned char               *ct_tx_buffer;
87         /** initial sze TX lock ptrs - number according to TX interfaces */
88         const struct szedata_lock   **ct_tx_lck_orig;
89         /** current sze TX lock ptrs - number according to TX interfaces */
90         const struct szedata_lock   **ct_tx_lck;
91         /** already written bytes in both locks */
92         unsigned int                *ct_tx_written_bytes;
93         /** remaining bytes (not written) within current lock */
94         unsigned int                *ct_tx_rem_bytes;
95         /** current pointers to locked memory */
96         unsigned char               **ct_tx_cur_ptr;
97         /** NUMA node closest to PCIe device, or -1 */
98         int                         numa_node;
99 };
100
101
102 #endif