999420a60cf31e9f19ae4c6d111b2ad0e74bc215
[dpdk.git] / lib / librte_pmd_e1000 / e1000_ethdev.h
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2013 Intel Corporation. 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 Intel Corporation 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
35 #ifndef _E1000_ETHDEV_H_
36 #define _E1000_ETHDEV_H_
37
38 /* need update link, bit flag */
39 #define E1000_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
40 #define E1000_FLAG_MAILBOX          (uint32_t)(1 << 1)
41
42 /*
43  * Defines that were not part of e1000_hw.h as they are not used by the FreeBSD
44  * driver.
45  */
46 #define E1000_ADVTXD_POPTS_TXSM     0x00000200 /* L4 Checksum offload request */
47 #define E1000_ADVTXD_POPTS_IXSM     0x00000100 /* IP Checksum offload request */
48 #define E1000_ADVTXD_TUCMD_L4T_RSV  0x00001800 /* L4 Packet TYPE of Reserved */
49 #define E1000_RXD_STAT_TMST         0x10000    /* Timestamped Packet indication */
50 #define E1000_RXD_ERR_CKSUM_BIT     29
51 #define E1000_RXD_ERR_CKSUM_MSK     3
52 #define E1000_ADVTXD_MACLEN_SHIFT   9          /* Bit shift for l2_len */
53 #define E1000_CTRL_EXT_EXTEND_VLAN  (1<<26)    /* EXTENDED VLAN */
54 #define IGB_VFTA_SIZE 128
55
56 /* structure for interrupt relative data */
57 struct e1000_interrupt {
58         uint32_t flags;
59         uint32_t mask;
60 };
61
62 /* local vfta copy */
63 struct e1000_vfta {
64         uint32_t vfta[IGB_VFTA_SIZE];
65 };
66
67 /*
68  * VF data which used by PF host only
69  */
70 #define E1000_MAX_VF_MC_ENTRIES         30
71 struct e1000_vf_info {
72         uint8_t vf_mac_addresses[ETHER_ADDR_LEN];
73         uint16_t vf_mc_hashes[E1000_MAX_VF_MC_ENTRIES];
74         uint16_t num_vf_mc_hashes;
75         uint16_t default_vf_vlan_id;
76         uint16_t vlans_enabled;
77         uint16_t pf_qos;
78         uint16_t vlan_count;
79         uint16_t tx_rate;
80 };
81
82 /*
83  * Structure to store private data for each driver instance (for each port).
84  */
85 struct e1000_adapter {
86         struct e1000_hw         hw;
87         struct e1000_hw_stats   stats;
88         struct e1000_interrupt  intr;
89         struct e1000_vfta       shadow_vfta;
90         struct e1000_vf_info    *vfdata;
91 };
92
93 #define E1000_DEV_PRIVATE_TO_HW(adapter) \
94         (&((struct e1000_adapter *)adapter)->hw)
95
96 #define E1000_DEV_PRIVATE_TO_STATS(adapter) \
97         (&((struct e1000_adapter *)adapter)->stats)
98
99 #define E1000_DEV_PRIVATE_TO_INTR(adapter) \
100         (&((struct e1000_adapter *)adapter)->intr)
101
102 #define E1000_DEV_PRIVATE_TO_VFTA(adapter) \
103         (&((struct e1000_adapter *)adapter)->shadow_vfta)
104
105 #define E1000_DEV_PRIVATE_TO_P_VFDATA(adapter) \
106         (&((struct e1000_adapter *)adapter)->vfdata)
107
108 /*
109  * RX/TX IGB function prototypes
110  */
111 void eth_igb_tx_queue_release(void *txq);
112 void eth_igb_rx_queue_release(void *rxq);
113 void igb_dev_clear_queues(struct rte_eth_dev *dev);
114
115 int eth_igb_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
116                 uint16_t nb_rx_desc, unsigned int socket_id,
117                 const struct rte_eth_rxconf *rx_conf,
118                 struct rte_mempool *mb_pool);
119
120 uint32_t eth_igb_rx_queue_count(struct rte_eth_dev *dev, 
121                 uint16_t rx_queue_id);
122
123 int eth_igb_rx_descriptor_done(void *rx_queue, uint16_t offset);
124
125 int eth_igb_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
126                 uint16_t nb_tx_desc, unsigned int socket_id,
127                 const struct rte_eth_txconf *tx_conf);
128
129 int eth_igb_rx_init(struct rte_eth_dev *dev);
130
131 void eth_igb_tx_init(struct rte_eth_dev *dev);
132
133 uint16_t eth_igb_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts,
134                 uint16_t nb_pkts);
135
136 uint16_t eth_igb_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts,
137                 uint16_t nb_pkts);
138
139 uint16_t eth_igb_recv_scattered_pkts(void *rxq,
140                 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
141
142 int eth_igbvf_rx_init(struct rte_eth_dev *dev);
143
144 void eth_igbvf_tx_init(struct rte_eth_dev *dev);
145
146 /*
147  * misc function prototypes
148  */
149 void igb_pf_host_init(struct rte_eth_dev *eth_dev);
150  
151 void igb_pf_mbx_process(struct rte_eth_dev *eth_dev);
152  
153 int igb_pf_host_configure(struct rte_eth_dev *eth_dev);
154
155 /*
156  * RX/TX EM function prototypes
157  */
158 void eth_em_tx_queue_release(void *txq);
159 void eth_em_rx_queue_release(void *rxq);
160
161 void em_dev_clear_queues(struct rte_eth_dev *dev);
162
163 int eth_em_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
164                 uint16_t nb_rx_desc, unsigned int socket_id,
165                 const struct rte_eth_rxconf *rx_conf,
166                 struct rte_mempool *mb_pool);
167
168 uint32_t eth_em_rx_queue_count(struct rte_eth_dev *dev, 
169                 uint16_t rx_queue_id);
170
171 int eth_em_rx_descriptor_done(void *rx_queue, uint16_t offset);
172
173 int eth_em_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
174                 uint16_t nb_tx_desc, unsigned int socket_id,
175                 const struct rte_eth_txconf *tx_conf);
176
177 int eth_em_rx_init(struct rte_eth_dev *dev);
178
179 void eth_em_tx_init(struct rte_eth_dev *dev);
180
181 uint16_t eth_em_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
182                 uint16_t nb_pkts);
183
184 uint16_t eth_em_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
185                 uint16_t nb_pkts);
186
187 uint16_t eth_em_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
188                 uint16_t nb_pkts);
189
190
191 #endif /* _E1000_ETHDEV_H_ */