xref: /freebsd/sys/dev/liquidio/lio_rxtx.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium, Inc.. All rights reserved.
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 Cavium, Inc. 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(S) 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 _LIO_RXTX_H_
35 #define _LIO_RXTX_H_
36 
37 /* Bit mask values for lio->ifstate */
38 #define LIO_IFSTATE_DROQ_OPS	0x01
39 #define LIO_IFSTATE_REGISTERED	0x02
40 #define LIO_IFSTATE_RUNNING	0x04
41 #define LIO_IFSTATE_DETACH	0x08
42 #define LIO_IFSTATE_RESETTING	0x10
43 
44 
45 /*
46  * Structure of a node in list of gather components maintained by
47  * NIC driver for each network device.
48  */
49 struct lio_gather {
50 	/* List manipulation. Next and prev pointers. */
51 	struct lio_stailq_node	node;
52 
53 	/* Size of the gather component at sg in bytes. */
54 	int	sg_size;
55 
56 	/*
57 	 * Gather component that can accommodate max sized fragment list
58 	 * received from the IP layer.
59 	 */
60 	struct lio_sg_entry	*sg;
61 
62 	uint64_t		sg_dma_ptr;
63 };
64 
65 union lio_tx_info {
66 	uint64_t	tx_info64;
67 	struct {
68 #if _BYTE_ORDER == _BIG_ENDIAN
69 		uint16_t	gso_size;
70 		uint16_t	gso_segs;
71 		uint32_t	reserved;
72 #else	/* _BYTE_ORDER == _LITTLE_ENDIAN */
73 		uint32_t	reserved;
74 		uint16_t	gso_segs;
75 		uint16_t	gso_size;
76 #endif
77 	}	s;
78 };
79 
80 int	lio_xmit(struct lio *lio, struct lio_instr_queue *iq,
81 		 struct mbuf **m_headp);
82 int	lio_mq_start_locked(if_t ifp, struct lio_instr_queue *iq);
83 int	lio_mq_start(if_t ifp, struct mbuf *m);
84 void	lio_qflush(if_t ifp);
85 #endif	/* _LIO_RXTX_H_ */
86