xref: /freebsd/sys/dev/liquidio/lio_rxtx.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1f173c2b7SSean Bruno /*
2f173c2b7SSean Bruno  *   BSD LICENSE
3f173c2b7SSean Bruno  *
4f173c2b7SSean Bruno  *   Copyright(c) 2017 Cavium, Inc.. All rights reserved.
5f173c2b7SSean Bruno  *   All rights reserved.
6f173c2b7SSean Bruno  *
7f173c2b7SSean Bruno  *   Redistribution and use in source and binary forms, with or without
8f173c2b7SSean Bruno  *   modification, are permitted provided that the following conditions
9f173c2b7SSean Bruno  *   are met:
10f173c2b7SSean Bruno  *
11f173c2b7SSean Bruno  *     * Redistributions of source code must retain the above copyright
12f173c2b7SSean Bruno  *       notice, this list of conditions and the following disclaimer.
13f173c2b7SSean Bruno  *     * Redistributions in binary form must reproduce the above copyright
14f173c2b7SSean Bruno  *       notice, this list of conditions and the following disclaimer in
15f173c2b7SSean Bruno  *       the documentation and/or other materials provided with the
16f173c2b7SSean Bruno  *       distribution.
17f173c2b7SSean Bruno  *     * Neither the name of Cavium, Inc. nor the names of its
18f173c2b7SSean Bruno  *       contributors may be used to endorse or promote products derived
19f173c2b7SSean Bruno  *       from this software without specific prior written permission.
20f173c2b7SSean Bruno  *
21f173c2b7SSean Bruno  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22f173c2b7SSean Bruno  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23f173c2b7SSean Bruno  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24f173c2b7SSean Bruno  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25f173c2b7SSean Bruno  *   OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26f173c2b7SSean Bruno  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27f173c2b7SSean Bruno  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28f173c2b7SSean Bruno  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29f173c2b7SSean Bruno  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30f173c2b7SSean Bruno  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31f173c2b7SSean Bruno  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32f173c2b7SSean Bruno  */
33f173c2b7SSean Bruno 
34f173c2b7SSean Bruno #ifndef _LIO_RXTX_H_
35f173c2b7SSean Bruno #define _LIO_RXTX_H_
36f173c2b7SSean Bruno 
37f173c2b7SSean Bruno /* Bit mask values for lio->ifstate */
38f173c2b7SSean Bruno #define LIO_IFSTATE_DROQ_OPS	0x01
39f173c2b7SSean Bruno #define LIO_IFSTATE_REGISTERED	0x02
40f173c2b7SSean Bruno #define LIO_IFSTATE_RUNNING	0x04
41f173c2b7SSean Bruno #define LIO_IFSTATE_DETACH	0x08
42f173c2b7SSean Bruno #define LIO_IFSTATE_RESETTING	0x10
43f173c2b7SSean Bruno 
44f173c2b7SSean Bruno 
45f173c2b7SSean Bruno /*
46f173c2b7SSean Bruno  * Structure of a node in list of gather components maintained by
47f173c2b7SSean Bruno  * NIC driver for each network device.
48f173c2b7SSean Bruno  */
49f173c2b7SSean Bruno struct lio_gather {
50f173c2b7SSean Bruno 	/* List manipulation. Next and prev pointers. */
51f173c2b7SSean Bruno 	struct lio_stailq_node	node;
52f173c2b7SSean Bruno 
53f173c2b7SSean Bruno 	/* Size of the gather component at sg in bytes. */
54f173c2b7SSean Bruno 	int	sg_size;
55f173c2b7SSean Bruno 
56f173c2b7SSean Bruno 	/*
57f173c2b7SSean Bruno 	 * Gather component that can accommodate max sized fragment list
58f173c2b7SSean Bruno 	 * received from the IP layer.
59f173c2b7SSean Bruno 	 */
60f173c2b7SSean Bruno 	struct lio_sg_entry	*sg;
61f173c2b7SSean Bruno 
62f173c2b7SSean Bruno 	uint64_t		sg_dma_ptr;
63f173c2b7SSean Bruno };
64f173c2b7SSean Bruno 
65f173c2b7SSean Bruno union lio_tx_info {
66f173c2b7SSean Bruno 	uint64_t	tx_info64;
67f173c2b7SSean Bruno 	struct {
68f173c2b7SSean Bruno #if _BYTE_ORDER == _BIG_ENDIAN
69f173c2b7SSean Bruno 		uint16_t	gso_size;
70f173c2b7SSean Bruno 		uint16_t	gso_segs;
71f173c2b7SSean Bruno 		uint32_t	reserved;
72f173c2b7SSean Bruno #else	/* _BYTE_ORDER == _LITTLE_ENDIAN */
73f173c2b7SSean Bruno 		uint32_t	reserved;
74f173c2b7SSean Bruno 		uint16_t	gso_segs;
75f173c2b7SSean Bruno 		uint16_t	gso_size;
76f173c2b7SSean Bruno #endif
77f173c2b7SSean Bruno 	}	s;
78f173c2b7SSean Bruno };
79f173c2b7SSean Bruno 
80f173c2b7SSean Bruno int	lio_xmit(struct lio *lio, struct lio_instr_queue *iq,
81f173c2b7SSean Bruno 		 struct mbuf **m_headp);
82*2c50292dSJustin Hibbits int	lio_mq_start_locked(if_t ifp, struct lio_instr_queue *iq);
83*2c50292dSJustin Hibbits int	lio_mq_start(if_t ifp, struct mbuf *m);
84*2c50292dSJustin Hibbits void	lio_qflush(if_t ifp);
85f173c2b7SSean Bruno #endif	/* _LIO_RXTX_H_ */
86