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