1a23fd118Syl150051 /*
2a23fd118Syl150051  * CDDL HEADER START
3a23fd118Syl150051  *
4a23fd118Syl150051  * The contents of this file are subject to the terms of the
5a23fd118Syl150051  * Common Development and Distribution License (the "License").
6a23fd118Syl150051  * You may not use this file except in compliance with the License.
7a23fd118Syl150051  *
8a23fd118Syl150051  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9a23fd118Syl150051  * or http://www.opensolaris.org/os/licensing.
10a23fd118Syl150051  * See the License for the specific language governing permissions
11a23fd118Syl150051  * and limitations under the License.
12a23fd118Syl150051  *
13a23fd118Syl150051  * When distributing Covered Code, include this CDDL HEADER in each
14a23fd118Syl150051  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15a23fd118Syl150051  * If applicable, add the following below this CDDL HEADER, with the
16a23fd118Syl150051  * fields enclosed by brackets "[]" replaced with your own identifying
17a23fd118Syl150051  * information: Portions Copyright [yyyy] [name of copyright owner]
18a23fd118Syl150051  *
19a23fd118Syl150051  * CDDL HEADER END
20a23fd118Syl150051  *
218347601bSyl150051  * Copyright (c) 2002-2006 Neterion, Inc.
22a23fd118Syl150051  */
23a23fd118Syl150051 
24*19397407SSherry Moore /*
25*19397407SSherry Moore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26*19397407SSherry Moore  * Use is subject to license terms.
27*19397407SSherry Moore  */
28*19397407SSherry Moore 
29a23fd118Syl150051 #ifndef XGE_HAL_DEVICE_H
30a23fd118Syl150051 #define XGE_HAL_DEVICE_H
31a23fd118Syl150051 
32a23fd118Syl150051 #include "xge-os-pal.h"
33a23fd118Syl150051 #include "xge-queue.h"
34a23fd118Syl150051 #include "xgehal-event.h"
35a23fd118Syl150051 #include "xgehal-config.h"
36a23fd118Syl150051 #include "xgehal-regs.h"
37a23fd118Syl150051 #include "xgehal-channel.h"
38a23fd118Syl150051 #include "xgehal-stats.h"
398347601bSyl150051 #include "xgehal-ring.h"
408347601bSyl150051 
418347601bSyl150051 __EXTERN_BEGIN_DECLS
42a23fd118Syl150051 
437eced415Sxw161283 #define XGE_HAL_VPD_LENGTH                              80
447eced415Sxw161283 #define XGE_HAL_CARD_XENA_VPD_ADDR                      0x50
457eced415Sxw161283 #define XGE_HAL_CARD_HERC_VPD_ADDR                      0x80
467eced415Sxw161283 #define XGE_HAL_VPD_READ_COMPLETE                       0x80
477eced415Sxw161283 #define XGE_HAL_VPD_BUFFER_SIZE                         128
48a23fd118Syl150051 #define XGE_HAL_DEVICE_XMSI_WAIT_MAX_MILLIS		500
49a23fd118Syl150051 #define XGE_HAL_DEVICE_CMDMEM_WAIT_MAX_MILLIS		500
50a23fd118Syl150051 #define XGE_HAL_DEVICE_QUIESCENT_WAIT_MAX_MILLIS	500
51a23fd118Syl150051 #define XGE_HAL_DEVICE_FAULT_WAIT_MAX_MILLIS		50
52a23fd118Syl150051 #define XGE_HAL_DEVICE_RESET_WAIT_MAX_MILLIS		250
53a23fd118Syl150051 #define XGE_HAL_DEVICE_SPDM_READY_WAIT_MAX_MILLIS	250  /* TODO */
54a23fd118Syl150051 
55a23fd118Syl150051 #define XGE_HAL_MAGIC					0x12345678
56a23fd118Syl150051 #define XGE_HAL_DEAD					0xDEADDEAD
57a23fd118Syl150051 #define XGE_HAL_DUMP_BUF_SIZE                           0x4000
58a23fd118Syl150051 
598347601bSyl150051 #define XGE_HAL_LRO_MAX_BUCKETS				32
60a23fd118Syl150051 
61a23fd118Syl150051 /**
62a23fd118Syl150051  * enum xge_hal_card_e - Xframe adapter type.
63a23fd118Syl150051  * @XGE_HAL_CARD_UNKNOWN: Unknown device.
64a23fd118Syl150051  * @XGE_HAL_CARD_XENA: Xframe I device.
65a23fd118Syl150051  * @XGE_HAL_CARD_HERC: Xframe II (PCI-266Mhz) device.
667eced415Sxw161283  * @XGE_HAL_CARD_TITAN: Xframe ER (PCI-266Mhz) device.
67a23fd118Syl150051  *
68a23fd118Syl150051  * Enumerates Xframe adapter types. The corresponding PCI device
69a23fd118Syl150051  * IDs are listed in the file xgehal-defs.h.
70a23fd118Syl150051  * (See XGE_PCI_DEVICE_ID_XENA_1, etc.)
71a23fd118Syl150051  *
72a23fd118Syl150051  * See also: xge_hal_device_check_id().
73a23fd118Syl150051  */
74a23fd118Syl150051 typedef enum xge_hal_card_e {
75a23fd118Syl150051 	XGE_HAL_CARD_UNKNOWN	= 0,
76a23fd118Syl150051 	XGE_HAL_CARD_XENA	= 1,
77a23fd118Syl150051 	XGE_HAL_CARD_HERC	= 2,
787eced415Sxw161283 	XGE_HAL_CARD_TITAN	= 3,
79a23fd118Syl150051 } xge_hal_card_e;
80a23fd118Syl150051 
81a23fd118Syl150051 /**
82a23fd118Syl150051  * struct xge_hal_device_attr_t - Device memory spaces.
83a23fd118Syl150051  * @regh0: BAR0 mapped memory handle (Solaris), or simply PCI device @pdev
84a23fd118Syl150051  *         (Linux and the rest.)
85a23fd118Syl150051  * @regh1: BAR1 mapped memory handle. Same comment as above.
86a23fd118Syl150051  * @bar0: BAR0 virtual address.
87a23fd118Syl150051  * @bar1: BAR1 virtual address.
88a23fd118Syl150051  * @irqh: IRQ handle (Solaris).
89a23fd118Syl150051  * @cfgh: Configuration space handle (Solaris), or PCI device @pdev (Linux).
90a23fd118Syl150051  * @pdev: PCI device object.
91a23fd118Syl150051  *
92a23fd118Syl150051  * Device memory spaces. Includes configuration, BAR0, BAR1, etc. per device
93a23fd118Syl150051  * mapped memories. Also, includes a pointer to OS-specific PCI device object.
94a23fd118Syl150051  */
95a23fd118Syl150051 typedef struct xge_hal_device_attr_t {
96a23fd118Syl150051 	pci_reg_h		regh0;
97a23fd118Syl150051 	pci_reg_h		regh1;
98a23fd118Syl150051 	pci_reg_h		regh2;
99a23fd118Syl150051 	char			*bar0;
100a23fd118Syl150051 	char			*bar1;
101a23fd118Syl150051 	char			*bar2;
102a23fd118Syl150051 	pci_irq_h		irqh;
103a23fd118Syl150051 	pci_cfg_h		cfgh;
104a23fd118Syl150051 	pci_dev_h		pdev;
105a23fd118Syl150051 } xge_hal_device_attr_t;
106a23fd118Syl150051 
107a23fd118Syl150051 /**
108a23fd118Syl150051  * enum xge_hal_device_link_state_e - Link state enumeration.
109a23fd118Syl150051  * @XGE_HAL_LINK_NONE: Invalid link state.
110a23fd118Syl150051  * @XGE_HAL_LINK_DOWN: Link is down.
111a23fd118Syl150051  * @XGE_HAL_LINK_UP: Link is up.
112a23fd118Syl150051  *
113a23fd118Syl150051  */
114a23fd118Syl150051 typedef enum xge_hal_device_link_state_e {
115a23fd118Syl150051 	XGE_HAL_LINK_NONE,
116a23fd118Syl150051 	XGE_HAL_LINK_DOWN,
117a23fd118Syl150051 	XGE_HAL_LINK_UP
118a23fd118Syl150051 } xge_hal_device_link_state_e;
119a23fd118Syl150051 
120a23fd118Syl150051 
121a23fd118Syl150051 /**
122a23fd118Syl150051  * enum xge_hal_pci_mode_e - PIC bus speed and mode specific enumeration.
123a23fd118Syl150051  * @XGE_HAL_PCI_33MHZ_MODE:		33 MHZ pci mode.
124a23fd118Syl150051  * @XGE_HAL_PCI_66MHZ_MODE:		66 MHZ pci mode.
125a23fd118Syl150051  * @XGE_HAL_PCIX_M1_66MHZ_MODE:		PCIX M1 66MHZ mode.
126a23fd118Syl150051  * @XGE_HAL_PCIX_M1_100MHZ_MODE:	PCIX M1 100MHZ mode.
127a23fd118Syl150051  * @XGE_HAL_PCIX_M1_133MHZ_MODE:	PCIX M1 133MHZ mode.
128a23fd118Syl150051  * @XGE_HAL_PCIX_M2_66MHZ_MODE:		PCIX M2 66MHZ mode.
129a23fd118Syl150051  * @XGE_HAL_PCIX_M2_100MHZ_MODE:	PCIX M2 100MHZ mode.
130a23fd118Syl150051  * @XGE_HAL_PCIX_M2_133MHZ_MODE:	PCIX M3 133MHZ mode.
131a23fd118Syl150051  * @XGE_HAL_PCIX_M1_RESERVED:		PCIX M1 reserved mode.
132a23fd118Syl150051  * @XGE_HAL_PCIX_M1_66MHZ_NS:		PCIX M1 66MHZ mode not supported.
133a23fd118Syl150051  * @XGE_HAL_PCIX_M1_100MHZ_NS:		PCIX M1 100MHZ mode not supported.
134a23fd118Syl150051  * @XGE_HAL_PCIX_M1_133MHZ_NS:		PCIX M1 133MHZ not supported.
135a23fd118Syl150051  * @XGE_HAL_PCIX_M2_RESERVED:		PCIX M2 reserved.
136a23fd118Syl150051  * @XGE_HAL_PCIX_533_RESERVED:		PCIX 533 reserved.
137a23fd118Syl150051  * @XGE_HAL_PCI_BASIC_MODE:		PCI basic mode, XENA specific value.
138a23fd118Syl150051  * @XGE_HAL_PCIX_BASIC_MODE:		PCIX basic mode, XENA specific value.
139a23fd118Syl150051  * @XGE_HAL_PCI_INVALID_MODE:		Invalid PCI or PCIX mode.
140a23fd118Syl150051  *
141a23fd118Syl150051  */
142a23fd118Syl150051 typedef enum xge_hal_pci_mode_e {
143a23fd118Syl150051 	XGE_HAL_PCI_33MHZ_MODE		= 0x0,
144a23fd118Syl150051 	XGE_HAL_PCI_66MHZ_MODE		= 0x1,
145a23fd118Syl150051 	XGE_HAL_PCIX_M1_66MHZ_MODE	= 0x2,
146a23fd118Syl150051 	XGE_HAL_PCIX_M1_100MHZ_MODE	= 0x3,
147a23fd118Syl150051 	XGE_HAL_PCIX_M1_133MHZ_MODE	= 0x4,
148a23fd118Syl150051 	XGE_HAL_PCIX_M2_66MHZ_MODE	= 0x5,
149a23fd118Syl150051 	XGE_HAL_PCIX_M2_100MHZ_MODE	= 0x6,
150a23fd118Syl150051 	XGE_HAL_PCIX_M2_133MHZ_MODE	= 0x7,
151a23fd118Syl150051 	XGE_HAL_PCIX_M1_RESERVED	= 0x8,
152a23fd118Syl150051 	XGE_HAL_PCIX_M1_66MHZ_NS	= 0xA,
153a23fd118Syl150051 	XGE_HAL_PCIX_M1_100MHZ_NS	= 0xB,
154a23fd118Syl150051 	XGE_HAL_PCIX_M1_133MHZ_NS	= 0xC,
155a23fd118Syl150051 	XGE_HAL_PCIX_M2_RESERVED	= 0xD,
156a23fd118Syl150051 	XGE_HAL_PCIX_533_RESERVED	= 0xE,
157a23fd118Syl150051 	XGE_HAL_PCI_BASIC_MODE		= 0x10,
158a23fd118Syl150051 	XGE_HAL_PCIX_BASIC_MODE		= 0x11,
159a23fd118Syl150051 	XGE_HAL_PCI_INVALID_MODE	= 0x12,
160a23fd118Syl150051 } xge_hal_pci_mode_e;
161a23fd118Syl150051 
162a23fd118Syl150051 /**
163a23fd118Syl150051  * enum xge_hal_pci_bus_frequency_e - PCI bus frequency enumeration.
164a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_33MHZ:	PCI bus frequency 33MHZ
165a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_66MHZ:	PCI bus frequency 66MHZ
166a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_100MHZ:	PCI bus frequency 100MHZ
167a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_133MHZ:	PCI bus frequency 133MHZ
1688347601bSyl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_200MHZ:	PCI bus frequency 200MHZ
1697eced415Sxw161283  * @XGE_HAL_PCI_BUS_FREQUENCY_250MHZ:	PCI bus frequency 250MHZ
170a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_266MHZ:	PCI bus frequency 266MHZ
171a23fd118Syl150051  * @XGE_HAL_PCI_BUS_FREQUENCY_UNKNOWN:	Unrecognized PCI bus frequency value.
172a23fd118Syl150051  *
173a23fd118Syl150051  */
174a23fd118Syl150051 typedef enum xge_hal_pci_bus_frequency_e {
175a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_33MHZ		= 33,
176a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_66MHZ		= 66,
177a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_100MHZ	= 100,
178a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_133MHZ	= 133,
179a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_200MHZ	= 200,
1807eced415Sxw161283 	XGE_HAL_PCI_BUS_FREQUENCY_250MHZ	= 250,
181a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_266MHZ	= 266,
182a23fd118Syl150051 	XGE_HAL_PCI_BUS_FREQUENCY_UNKNOWN	= 0
183a23fd118Syl150051 } xge_hal_pci_bus_frequency_e;
184a23fd118Syl150051 
185a23fd118Syl150051 /**
186a23fd118Syl150051  * enum xge_hal_pci_bus_width_e - PCI bus width enumeration.
187a23fd118Syl150051  * @XGE_HAL_PCI_BUS_WIDTH_64BIT:	64 bit bus width.
188a23fd118Syl150051  * @XGE_HAL_PCI_BUS_WIDTH_32BIT:	32 bit bus width.
189a23fd118Syl150051  * @XGE_HAL_PCI_BUS_WIDTH_UNKNOWN:  unknown bus width.
190a23fd118Syl150051  *
191a23fd118Syl150051  */
192a23fd118Syl150051 typedef enum xge_hal_pci_bus_width_e {
193a23fd118Syl150051 	XGE_HAL_PCI_BUS_WIDTH_64BIT	= 0,
194a23fd118Syl150051 	XGE_HAL_PCI_BUS_WIDTH_32BIT	= 1,
195a23fd118Syl150051 	XGE_HAL_PCI_BUS_WIDTH_UNKNOWN	= 2,
196a23fd118Syl150051 } xge_hal_pci_bus_width_e;
197a23fd118Syl150051 
198a23fd118Syl150051 #if defined (XGE_HAL_CONFIG_LRO)
199a23fd118Syl150051 
200a23fd118Syl150051 #define IP_TOTAL_LENGTH_OFFSET			2
201a23fd118Syl150051 #define IP_FAST_PATH_HDR_MASK			0x45
202a23fd118Syl150051 #define TCP_FAST_PATH_HDR_MASK1			0x50
203a23fd118Syl150051 #define TCP_FAST_PATH_HDR_MASK2			0x10
204a23fd118Syl150051 #define TCP_FAST_PATH_HDR_MASK3			0x18
205a23fd118Syl150051 #define IP_SOURCE_ADDRESS_OFFSET		12
206a23fd118Syl150051 #define IP_DESTINATION_ADDRESS_OFFSET		16
207a23fd118Syl150051 #define TCP_DESTINATION_PORT_OFFSET		2
208a23fd118Syl150051 #define TCP_SOURCE_PORT_OFFSET			0
209a23fd118Syl150051 #define TCP_DATA_OFFSET_OFFSET			12
210a23fd118Syl150051 #define TCP_WINDOW_OFFSET			14
211a23fd118Syl150051 #define TCP_SEQUENCE_NUMBER_OFFSET		4
212a23fd118Syl150051 #define TCP_ACKNOWLEDGEMENT_NUMBER_OFFSET	8
213a23fd118Syl150051 
214a23fd118Syl150051 typedef struct tcplro {
215a23fd118Syl150051 	u16   source;
216a23fd118Syl150051 	u16   dest;
217a23fd118Syl150051 	u32   seq;
218a23fd118Syl150051 	u32   ack_seq;
219a23fd118Syl150051 	u8    doff_res;
220a23fd118Syl150051 	u8    ctrl;
221a23fd118Syl150051 	u16   window;
222a23fd118Syl150051 	u16   check;
223a23fd118Syl150051 	u16   urg_ptr;
224a23fd118Syl150051 } tcplro_t;
225a23fd118Syl150051 
226a23fd118Syl150051 typedef struct iplro {
227a23fd118Syl150051 	u8    version_ihl;
228a23fd118Syl150051 	u8    tos;
229a23fd118Syl150051 	u16   tot_len;
230a23fd118Syl150051 	u16   id;
231a23fd118Syl150051 	u16   frag_off;
232a23fd118Syl150051 	u8    ttl;
233a23fd118Syl150051 	u8    protocol;
234a23fd118Syl150051 	u16   check;
235a23fd118Syl150051 	u32   saddr;
236a23fd118Syl150051 	u32   daddr;
237a23fd118Syl150051 	/*The options start here. */
238a23fd118Syl150051 } iplro_t;
239a23fd118Syl150051 
240a23fd118Syl150051 /*
241a23fd118Syl150051  * LRO object, one per each LRO session.
242a23fd118Syl150051 */
243a23fd118Syl150051 typedef struct lro {
244a23fd118Syl150051 	/* non-linear: contains scatter-gather list of
245a23fd118Syl150051 	xframe-mapped received buffers */
246a23fd118Syl150051 	OS_NETSTACK_BUF		os_buf;
247a23fd118Syl150051 	OS_NETSTACK_BUF		os_buf_end;
248a23fd118Syl150051 
249a23fd118Syl150051 	/* link layer header of the first frame;
250a23fd118Syl150051 	remains intack throughout the processing */
251a23fd118Syl150051 	u8			*ll_hdr;
252a23fd118Syl150051 
253a23fd118Syl150051 	/* IP header - gets _collapsed_ */
254a23fd118Syl150051 	iplro_t			*ip_hdr;
255a23fd118Syl150051 
256a23fd118Syl150051 	/* transport header - gets _collapsed_ */
257a23fd118Syl150051 	tcplro_t		*tcp_hdr;
258a23fd118Syl150051 
259a23fd118Syl150051 	/* Next tcp sequence number */
260a23fd118Syl150051 	u32			tcp_next_seq_num;
261a23fd118Syl150051 	/* Current tcp seq & ack */
262a23fd118Syl150051 	u32			tcp_seq_num;
263a23fd118Syl150051 	u32			tcp_ack_num;
264a23fd118Syl150051 
265a23fd118Syl150051 	/* total number of accumulated (so far) frames */
266a23fd118Syl150051 	int			sg_num;
267a23fd118Syl150051 
268a23fd118Syl150051 	/* total data length */
269a23fd118Syl150051 	int			total_length;
270a23fd118Syl150051 
271a23fd118Syl150051 	/* receive side hash value, available from Hercules */
272a23fd118Syl150051 	u32			rth_value;
273a23fd118Syl150051 
274a23fd118Syl150051 	/* In use */
275a23fd118Syl150051 	u8			in_use;
276a23fd118Syl150051 
277a23fd118Syl150051 	/* Total length of the fragments clubbed with the inital frame */
278a23fd118Syl150051 	u32			frags_len;
2798347601bSyl150051 
2808347601bSyl150051 	/* LRO frame contains time stamp, if (ts_off != -1) */
2818347601bSyl150051 	int 			ts_off;
2828347601bSyl150051 
283a23fd118Syl150051 } lro_t;
284a23fd118Syl150051 #endif
285a23fd118Syl150051 
286a23fd118Syl150051 /*
287a23fd118Syl150051  * xge_hal_spdm_entry_t
288a23fd118Syl150051  *
289a23fd118Syl150051  * Represents a single spdm entry in the SPDM table.
290a23fd118Syl150051  */
291a23fd118Syl150051 typedef struct xge_hal_spdm_entry_t {
292a23fd118Syl150051 	xge_hal_ipaddr_t  src_ip;
293a23fd118Syl150051 	xge_hal_ipaddr_t  dst_ip;
294a23fd118Syl150051 	u32 jhash_value;
295a23fd118Syl150051 	u16 l4_sp;
296a23fd118Syl150051 	u16 l4_dp;
297a23fd118Syl150051 	u16 spdm_entry;
298a23fd118Syl150051 	u8  in_use;
299a23fd118Syl150051 	u8  is_tcp;
300a23fd118Syl150051 	u8  is_ipv4;
301a23fd118Syl150051 	u8  tgt_queue;
302a23fd118Syl150051 } xge_hal_spdm_entry_t;
303a23fd118Syl150051 
3047eced415Sxw161283 #if defined(XGE_HAL_CONFIG_LRO)
3057eced415Sxw161283 typedef struct {
3067eced415Sxw161283 	lro_t			lro_pool[XGE_HAL_LRO_MAX_BUCKETS];
3077eced415Sxw161283 	int			lro_next_idx;
3087eced415Sxw161283 	lro_t			*lro_recent;
3097eced415Sxw161283 } xge_hal_lro_desc_t;
3108347601bSyl150051 #endif
3117eced415Sxw161283 /*
3127eced415Sxw161283  * xge_hal_vpd_data_t
3137eced415Sxw161283  *
3147eced415Sxw161283  * Represents vpd capabilty structure
3157eced415Sxw161283  */
3167eced415Sxw161283 typedef struct xge_hal_vpd_data_t {
3177eced415Sxw161283         u8      product_name[XGE_HAL_VPD_LENGTH];
3187eced415Sxw161283         u8      serial_num[XGE_HAL_VPD_LENGTH];
3197eced415Sxw161283 } xge_hal_vpd_data_t;
320a23fd118Syl150051 
321a23fd118Syl150051 /*
322a23fd118Syl150051  * xge_hal_device_t
323a23fd118Syl150051  *
324a23fd118Syl150051  * HAL device object. Represents Xframe.
325a23fd118Syl150051  */
326a23fd118Syl150051 typedef struct {
3278347601bSyl150051 	unsigned int		magic;
328a23fd118Syl150051 	pci_reg_h		regh0;
329a23fd118Syl150051 	pci_reg_h		regh1;
330a23fd118Syl150051 	pci_reg_h		regh2;
331a23fd118Syl150051 	char			*bar0;
332a23fd118Syl150051 	char			*isrbar0;
333a23fd118Syl150051 	char			*bar1;
334a23fd118Syl150051 	char			*bar2;
335a23fd118Syl150051 	pci_irq_h		irqh;
336a23fd118Syl150051 	pci_cfg_h		cfgh;
337a23fd118Syl150051 	pci_dev_h		pdev;
338a23fd118Syl150051 	xge_hal_pci_config_t	pci_config_space;
3397eced415Sxw161283 	xge_hal_pci_config_t	pci_config_space_bios;
340a23fd118Syl150051 	xge_hal_device_config_t	config;
341a23fd118Syl150051 	xge_list_t		free_channels;
342a23fd118Syl150051 	xge_list_t		fifo_channels;
343a23fd118Syl150051 	xge_list_t		ring_channels;
344a23fd118Syl150051 	volatile int		is_initialized;
345a23fd118Syl150051 	volatile int		terminating;
346a23fd118Syl150051 	xge_hal_stats_t		stats;
347a23fd118Syl150051 	macaddr_t		macaddr[1];
348a23fd118Syl150051 	xge_queue_h		queueh;
349a23fd118Syl150051 	volatile int		mcast_refcnt;
350a23fd118Syl150051 	int			is_promisc;
351a23fd118Syl150051 	volatile xge_hal_device_link_state_e	link_state;
352a23fd118Syl150051 	void			*upper_layer_info;
353a23fd118Syl150051 	xge_hal_device_attr_t	orig_attr;
354a23fd118Syl150051 	u16			device_id;
355a23fd118Syl150051 	u8			revision;
356a23fd118Syl150051 	int			msi_enabled;
357a23fd118Syl150051 	int			hw_is_initialized;
358a23fd118Syl150051 	u64			inject_serr;
359a23fd118Syl150051 	u64			inject_ecc;
360a23fd118Syl150051 	u8			inject_bad_tcode;
361a23fd118Syl150051 	int			inject_bad_tcode_for_chan_type;
362a23fd118Syl150051         int                     reset_needed_after_close;
3638347601bSyl150051 	int			tti_enabled;
3648347601bSyl150051 	xge_hal_tti_config_t	bimodal_tti[XGE_HAL_MAX_RING_NUM];
3658347601bSyl150051 	int			bimodal_timer_val_us;
3668347601bSyl150051 	int			bimodal_urange_a_en;
3678347601bSyl150051 	int			bimodal_intr_cnt;
368a23fd118Syl150051 	char			*spdm_mem_base;
369a23fd118Syl150051 	u16			spdm_max_entries;
370a23fd118Syl150051 	xge_hal_spdm_entry_t	**spdm_table;
371a23fd118Syl150051 	spinlock_t		spdm_lock;
372a23fd118Syl150051 #if defined(XGE_HAL_CONFIG_LRO)
3737eced415Sxw161283         xge_hal_lro_desc_t      lro_desc[XGE_HAL_MAX_RING_NUM];
374a23fd118Syl150051 #endif
375a23fd118Syl150051 	spinlock_t		xena_post_lock;
3768347601bSyl150051 
3778347601bSyl150051 	/* bimodal workload stats */
3788347601bSyl150051 	int			irq_workload_rxd[XGE_HAL_MAX_RING_NUM];
3798347601bSyl150051 	int			irq_workload_rxcnt[XGE_HAL_MAX_RING_NUM];
3808347601bSyl150051 	int			irq_workload_rxlen[XGE_HAL_MAX_RING_NUM];
3818347601bSyl150051 	int			irq_workload_txd[XGE_HAL_MAX_FIFO_NUM];
3828347601bSyl150051 	int			irq_workload_txcnt[XGE_HAL_MAX_FIFO_NUM];
3838347601bSyl150051 	int			irq_workload_txlen[XGE_HAL_MAX_FIFO_NUM];
3848347601bSyl150051 
3858347601bSyl150051 	int			mtu_first_time_set;
386a23fd118Syl150051 	u64			rxufca_lbolt;
387a23fd118Syl150051 	u64			rxufca_lbolt_time;
388a23fd118Syl150051 	u64			rxufca_intr_thres;
389a23fd118Syl150051 	char*                   dump_buf;
390a23fd118Syl150051 	xge_hal_pci_mode_e	pci_mode;
391a23fd118Syl150051 	xge_hal_pci_bus_frequency_e bus_frequency;
392a23fd118Syl150051 	xge_hal_pci_bus_width_e	bus_width;
3937eced415Sxw161283 	xge_hal_vpd_data_t      vpd_data;
394a23fd118Syl150051 	volatile int		in_poll;
3957eced415Sxw161283 	u64			msix_vector_table[XGE_HAL_MAX_MSIX_MESSAGES_WITH_ADDR];
396a23fd118Syl150051 } xge_hal_device_t;
397a23fd118Syl150051 
398a23fd118Syl150051 
399a23fd118Syl150051 /* ========================== PRIVATE API ================================= */
400a23fd118Syl150051 
4017eced415Sxw161283 void
4027eced415Sxw161283 __hal_device_event_queued(void *data, int event_type);
4037eced415Sxw161283 
4047eced415Sxw161283 xge_hal_status_e
4057eced415Sxw161283 __hal_device_set_swapper(xge_hal_device_t *hldev);
4067eced415Sxw161283 
4077eced415Sxw161283 xge_hal_status_e
4087eced415Sxw161283 __hal_device_rth_it_configure(xge_hal_device_t *hldev);
4097eced415Sxw161283 
4107eced415Sxw161283 xge_hal_status_e
4117eced415Sxw161283 __hal_device_rth_spdm_configure(xge_hal_device_t *hldev);
4127eced415Sxw161283 
4137eced415Sxw161283 xge_hal_status_e
4147eced415Sxw161283 __hal_verify_pcc_idle(xge_hal_device_t *hldev, u64 adp_status);
4157eced415Sxw161283 
4167eced415Sxw161283 xge_hal_status_e
4177eced415Sxw161283 __hal_device_handle_pic(xge_hal_device_t *hldev, u64 reason);
4187eced415Sxw161283 
4197eced415Sxw161283 xge_hal_status_e
4207eced415Sxw161283 __hal_read_spdm_entry_line(xge_hal_device_t *hldev, u8 spdm_line,
4217eced415Sxw161283                         u16 spdm_entry, u64 *spdm_line_val);
4227eced415Sxw161283 
423a23fd118Syl150051 void __hal_pio_mem_write32_upper(pci_dev_h pdev, pci_reg_h regh, u32 val,
424a23fd118Syl150051 			void *addr);
425a23fd118Syl150051 
426a23fd118Syl150051 void __hal_pio_mem_write32_lower(pci_dev_h pdev, pci_reg_h regh, u32 val,
427a23fd118Syl150051 			void *addr);
4287eced415Sxw161283 void __hal_device_get_vpd_data(xge_hal_device_t *hldev);
429a23fd118Syl150051 
430a23fd118Syl150051 xge_hal_status_e
431a23fd118Syl150051 __hal_device_handle_txpic(xge_hal_device_t *hldev, u64 reason);
432a23fd118Syl150051 
433a23fd118Syl150051 xge_hal_status_e
434a23fd118Syl150051 __hal_device_handle_txdma(xge_hal_device_t *hldev, u64 reason);
435a23fd118Syl150051 
436a23fd118Syl150051 xge_hal_status_e
437a23fd118Syl150051 __hal_device_handle_txmac(xge_hal_device_t *hldev, u64 reason);
438a23fd118Syl150051 
439a23fd118Syl150051 xge_hal_status_e
440a23fd118Syl150051 __hal_device_handle_txxgxs(xge_hal_device_t *hldev, u64 reason);
441a23fd118Syl150051 
442a23fd118Syl150051 xge_hal_status_e
443a23fd118Syl150051 __hal_device_handle_rxpic(xge_hal_device_t *hldev, u64 reason);
444a23fd118Syl150051 
445a23fd118Syl150051 xge_hal_status_e
446a23fd118Syl150051 __hal_device_handle_rxdma(xge_hal_device_t *hldev, u64 reason);
447a23fd118Syl150051 
448a23fd118Syl150051 xge_hal_status_e
449a23fd118Syl150051 __hal_device_handle_rxmac(xge_hal_device_t *hldev, u64 reason);
450a23fd118Syl150051 
451a23fd118Syl150051 xge_hal_status_e
452a23fd118Syl150051 __hal_device_handle_rxxgxs(xge_hal_device_t *hldev, u64 reason);
453a23fd118Syl150051 
454a23fd118Syl150051 xge_hal_status_e
455a23fd118Syl150051 __hal_device_handle_mc(xge_hal_device_t *hldev, u64 reason);
456a23fd118Syl150051 
457a23fd118Syl150051 xge_hal_status_e
458a23fd118Syl150051 __hal_device_register_poll(xge_hal_device_t *hldev, u64 *reg, int op, u64 mask,
459a23fd118Syl150051 			int max_millis);
460a23fd118Syl150051 xge_hal_status_e
461a23fd118Syl150051 __hal_device_rts_mac_configure(xge_hal_device_t *hldev);
462a23fd118Syl150051 
4638347601bSyl150051 xge_hal_status_e
4648347601bSyl150051 __hal_device_rts_qos_configure(xge_hal_device_t *hldev);
4658347601bSyl150051 
4668347601bSyl150051 xge_hal_status_e
4677eced415Sxw161283 __hal_device_rts_port_configure(xge_hal_device_t *hldev);
4687eced415Sxw161283 
4697eced415Sxw161283 xge_hal_status_e
4708347601bSyl150051 __hal_device_rti_configure(xge_hal_device_t *hldev, int runtime);
4718347601bSyl150051 
4727eced415Sxw161283 void
4737eced415Sxw161283 __hal_device_msi_intr_endis(xge_hal_device_t *hldev, int flag);
4747eced415Sxw161283 
4757eced415Sxw161283 void
4767eced415Sxw161283 __hal_device_msix_intr_endis(xge_hal_device_t *hldev,
4777eced415Sxw161283 			      xge_hal_channel_t *channel, int flag);
4787eced415Sxw161283 
479a23fd118Syl150051 /* =========================== PUBLIC API ================================= */
480a23fd118Syl150051 
481a23fd118Syl150051 unsigned int
482a23fd118Syl150051 __hal_fix_time_ival_herc(xge_hal_device_t *hldev,
483a23fd118Syl150051 			 unsigned int time_ival);
484a23fd118Syl150051 xge_hal_status_e
485a23fd118Syl150051 xge_hal_rts_rth_itable_set(xge_hal_device_t *hldev, u8 *itable,
486a23fd118Syl150051 		u32 itable_size);
487a23fd118Syl150051 
488a23fd118Syl150051 void
489a23fd118Syl150051 xge_hal_rts_rth_set(xge_hal_device_t *hldev, u8 def_q, u64 hash_type,
490a23fd118Syl150051 		u16 bucket_size);
491a23fd118Syl150051 
492a23fd118Syl150051 void
493a23fd118Syl150051 xge_hal_rts_rth_init(xge_hal_device_t *hldev);
494a23fd118Syl150051 
495a23fd118Syl150051 void
496a23fd118Syl150051 xge_hal_rts_rth_clr(xge_hal_device_t *hldev);
497a23fd118Syl150051 
498a23fd118Syl150051 void
499a23fd118Syl150051 xge_hal_rts_rth_start(xge_hal_device_t *hldev);
500a23fd118Syl150051 
501a23fd118Syl150051 void
502a23fd118Syl150051 xge_hal_rts_rth_stop(xge_hal_device_t *hldev);
503a23fd118Syl150051 
504a23fd118Syl150051 void
505a23fd118Syl150051 xge_hal_device_rts_rth_key_set(xge_hal_device_t *hldev, u8 KeySize, u8 *Key);
506a23fd118Syl150051 
507a23fd118Syl150051 xge_hal_status_e
508a23fd118Syl150051 xge_hal_device_rts_mac_enable(xge_hal_device_h devh, int index, macaddr_t macaddr);
509a23fd118Syl150051 
510a23fd118Syl150051 xge_hal_status_e
511a23fd118Syl150051 xge_hal_device_rts_mac_disable(xge_hal_device_h devh, int index);
512a23fd118Syl150051 
5137eced415Sxw161283 int xge_hal_reinitialize_hw(xge_hal_device_t * hldev);
5147eced415Sxw161283 
5157eced415Sxw161283 xge_hal_status_e xge_hal_fix_rldram_ecc_error(xge_hal_device_t * hldev);
5168347601bSyl150051 /**
5178347601bSyl150051  * xge_hal_device_rti_reconfigure
5187eced415Sxw161283  * @hldev: Hal Device
5198347601bSyl150051  */
5208347601bSyl150051 static inline xge_hal_status_e
xge_hal_device_rti_reconfigure(xge_hal_device_t * hldev)5218347601bSyl150051 xge_hal_device_rti_reconfigure(xge_hal_device_t *hldev)
5228347601bSyl150051 {
5238347601bSyl150051 	return __hal_device_rti_configure(hldev, 1);
5248347601bSyl150051 }
525a23fd118Syl150051 
526a23fd118Syl150051 /**
5277eced415Sxw161283  * xge_hal_device_rts_port_reconfigure
5287eced415Sxw161283  * @hldev: Hal Device
5297eced415Sxw161283  */
5307eced415Sxw161283 static inline xge_hal_status_e
xge_hal_device_rts_port_reconfigure(xge_hal_device_t * hldev)5317eced415Sxw161283 xge_hal_device_rts_port_reconfigure(xge_hal_device_t *hldev)
5327eced415Sxw161283 {
5337eced415Sxw161283 	return __hal_device_rts_port_configure(hldev);
5347eced415Sxw161283 }
5357eced415Sxw161283 
5367eced415Sxw161283 /**
537a23fd118Syl150051  * xge_hal_device_is_initialized - Returns 0 if device is not
538a23fd118Syl150051  * initialized, non-zero otherwise.
539a23fd118Syl150051  * @devh: HAL device handle.
540a23fd118Syl150051  *
541a23fd118Syl150051  * Returns 0 if device is not initialized, non-zero otherwise.
542a23fd118Syl150051  */
543a23fd118Syl150051 static inline int
xge_hal_device_is_initialized(xge_hal_device_h devh)544a23fd118Syl150051 xge_hal_device_is_initialized(xge_hal_device_h devh)
545a23fd118Syl150051 {
546a23fd118Syl150051 	return ((xge_hal_device_t*)devh)->is_initialized;
547a23fd118Syl150051 }
548a23fd118Syl150051 
549a23fd118Syl150051 
550a23fd118Syl150051 /**
551a23fd118Syl150051  * xge_hal_device_in_poll - non-zero, if xge_hal_device_poll() is executing.
552a23fd118Syl150051  * @devh: HAL device handle.
553a23fd118Syl150051  *
554a23fd118Syl150051  * Returns non-zero if xge_hal_device_poll() is executing, and 0 - otherwise.
555a23fd118Syl150051  */
556a23fd118Syl150051 static inline int
xge_hal_device_in_poll(xge_hal_device_h devh)557a23fd118Syl150051 xge_hal_device_in_poll(xge_hal_device_h devh)
558a23fd118Syl150051 {
559a23fd118Syl150051 	return ((xge_hal_device_t*)devh)->in_poll;
560a23fd118Syl150051 }
561a23fd118Syl150051 
562a23fd118Syl150051 
563a23fd118Syl150051 /**
564a23fd118Syl150051  * xge_hal_device_inject_ecc - Inject ECC error.
565a23fd118Syl150051  * @devh: HAL device, pointer to xge_hal_device_t structure.
566a23fd118Syl150051  * @err_reg: Contains the error register.
567a23fd118Syl150051  *
568a23fd118Syl150051  * This function is used to inject ECC error into the driver flow.
569a23fd118Syl150051  * This facility can be used to test the driver flow in the
570a23fd118Syl150051  * case of ECC error is reported by the firmware.
571a23fd118Syl150051  *
572a23fd118Syl150051  * Returns: void
573a23fd118Syl150051  * See also: xge_hal_device_inject_serr(),
574a23fd118Syl150051  * xge_hal_device_inject_bad_tcode()
575a23fd118Syl150051  */
576a23fd118Syl150051 static inline void
xge_hal_device_inject_ecc(xge_hal_device_h devh,u64 err_reg)577a23fd118Syl150051 xge_hal_device_inject_ecc(xge_hal_device_h devh, u64 err_reg)
578a23fd118Syl150051 {
579a23fd118Syl150051         ((xge_hal_device_t*)devh)->inject_ecc = err_reg;
580a23fd118Syl150051 }
581a23fd118Syl150051 
582a23fd118Syl150051 
583a23fd118Syl150051 /**
584a23fd118Syl150051  * xge_hal_device_inject_serr - Inject SERR error.
585a23fd118Syl150051  * @devh: HAL device, pointer to xge_hal_device_t structure.
586a23fd118Syl150051  * @err_reg: Contains the error register.
587a23fd118Syl150051  *
588a23fd118Syl150051  * This function is used to inject SERR error into the driver flow.
589a23fd118Syl150051  * This facility can be used to test the driver flow in the
590a23fd118Syl150051  * case of SERR error is reported by firmware.
591a23fd118Syl150051  *
592a23fd118Syl150051  * Returns: void
593a23fd118Syl150051  * See also: xge_hal_device_inject_ecc(),
594a23fd118Syl150051  * xge_hal_device_inject_bad_tcode()
595a23fd118Syl150051  */
596a23fd118Syl150051 static inline void
xge_hal_device_inject_serr(xge_hal_device_h devh,u64 err_reg)597a23fd118Syl150051 xge_hal_device_inject_serr(xge_hal_device_h devh, u64 err_reg)
598a23fd118Syl150051 {
599a23fd118Syl150051         ((xge_hal_device_t*)devh)->inject_serr = err_reg;
600a23fd118Syl150051 }
601a23fd118Syl150051 
602a23fd118Syl150051 
603a23fd118Syl150051 /**
604a23fd118Syl150051  * xge_hal_device_inject_bad_tcode - Inject  Bad transfer code.
605a23fd118Syl150051  * @devh: HAL device, pointer to xge_hal_device_t structure.
606a23fd118Syl150051  * @chan_type: Channel type (fifo/ring).
607a23fd118Syl150051  * @t_code: Transfer code.
608a23fd118Syl150051  *
609a23fd118Syl150051  * This function is used to inject bad (Tx/Rx Data)transfer code
610a23fd118Syl150051  * into the driver flow.
611a23fd118Syl150051  *
612a23fd118Syl150051  * This facility can be used to test the driver flow in the
613a23fd118Syl150051  * case of bad transfer code reported by firmware for a Tx/Rx data
614a23fd118Syl150051  * transfer.
615a23fd118Syl150051  *
616a23fd118Syl150051  * Returns: void
617a23fd118Syl150051  * See also: xge_hal_device_inject_ecc(), xge_hal_device_inject_serr()
618a23fd118Syl150051  */
619a23fd118Syl150051 static inline void
xge_hal_device_inject_bad_tcode(xge_hal_device_h devh,int chan_type,u8 t_code)620a23fd118Syl150051 xge_hal_device_inject_bad_tcode(xge_hal_device_h devh, int chan_type, u8 t_code)
621a23fd118Syl150051 {
622a23fd118Syl150051         ((xge_hal_device_t*)devh)->inject_bad_tcode_for_chan_type = chan_type;
623a23fd118Syl150051         ((xge_hal_device_t*)devh)->inject_bad_tcode = t_code;
624a23fd118Syl150051 }
625a23fd118Syl150051 
626a23fd118Syl150051 void xge_hal_device_msi_enable(xge_hal_device_h	devh);
627a23fd118Syl150051 
628a23fd118Syl150051 /*
629a23fd118Syl150051  * xge_hal_device_msi_mode - Is MSI enabled?
630a23fd118Syl150051  * @devh: HAL device handle.
631a23fd118Syl150051  *
632a23fd118Syl150051  * Returns 0 if MSI is enabled for the specified device,
633a23fd118Syl150051  * non-zero otherwise.
634a23fd118Syl150051  */
635a23fd118Syl150051 static inline int
xge_hal_device_msi_mode(xge_hal_device_h devh)636a23fd118Syl150051 xge_hal_device_msi_mode(xge_hal_device_h devh)
637a23fd118Syl150051 {
638a23fd118Syl150051 	return ((xge_hal_device_t*)devh)->msi_enabled;
639a23fd118Syl150051 }
640a23fd118Syl150051 
641a23fd118Syl150051 /**
642a23fd118Syl150051  * xge_hal_device_queue - Get per-device event queue.
643a23fd118Syl150051  * @devh: HAL device handle.
644a23fd118Syl150051  *
645a23fd118Syl150051  * Returns: event queue associated with the specified HAL device.
646a23fd118Syl150051  */
647a23fd118Syl150051 static inline xge_queue_h
xge_hal_device_queue(xge_hal_device_h devh)648a23fd118Syl150051 xge_hal_device_queue (xge_hal_device_h devh)
649a23fd118Syl150051 {
650a23fd118Syl150051 	return ((xge_hal_device_t*)devh)->queueh;
651a23fd118Syl150051 }
652a23fd118Syl150051 
653a23fd118Syl150051 /**
654a23fd118Syl150051  * xge_hal_device_attr - Get original (user-specified) device
655a23fd118Syl150051  * attributes.
656a23fd118Syl150051  * @devh: HAL device handle.
657a23fd118Syl150051  *
658a23fd118Syl150051  * Returns: original (user-specified) device attributes.
659a23fd118Syl150051  */
660a23fd118Syl150051 static inline xge_hal_device_attr_t*
xge_hal_device_attr(xge_hal_device_h devh)661a23fd118Syl150051 xge_hal_device_attr(xge_hal_device_h devh)
662a23fd118Syl150051 {
663a23fd118Syl150051 	return &((xge_hal_device_t*)devh)->orig_attr;
664a23fd118Syl150051 }
665a23fd118Syl150051 
666a23fd118Syl150051 /**
667a23fd118Syl150051  * xge_hal_device_private_set - Set ULD context.
668a23fd118Syl150051  * @devh: HAL device handle.
669a23fd118Syl150051  * @data: pointer to ULD context
670a23fd118Syl150051  *
671a23fd118Syl150051  * Use HAL device to set upper-layer driver (ULD) context.
672a23fd118Syl150051  *
673a23fd118Syl150051  * See also: xge_hal_device_from_private(), xge_hal_device_private()
674a23fd118Syl150051  */
675a23fd118Syl150051 static inline void
xge_hal_device_private_set(xge_hal_device_h devh,void * data)676a23fd118Syl150051 xge_hal_device_private_set(xge_hal_device_h devh, void *data)
677a23fd118Syl150051 {
678a23fd118Syl150051 	((xge_hal_device_t*)devh)->upper_layer_info = data;
679a23fd118Syl150051 }
680a23fd118Syl150051 
681a23fd118Syl150051 /**
682a23fd118Syl150051  * xge_hal_device_private - Get ULD context.
683a23fd118Syl150051  * @devh: HAL device handle.
684a23fd118Syl150051  *
685a23fd118Syl150051  * Use HAL device to get upper-layer driver (ULD) context.
686a23fd118Syl150051  *
687a23fd118Syl150051  * Returns:  ULD context.
688a23fd118Syl150051  *
689a23fd118Syl150051  * See also: xge_hal_device_from_private(), xge_hal_device_private_set()
690a23fd118Syl150051  */
691a23fd118Syl150051 static inline void*
xge_hal_device_private(xge_hal_device_h devh)692a23fd118Syl150051 xge_hal_device_private(xge_hal_device_h devh)
693a23fd118Syl150051 {
694a23fd118Syl150051 	return ((xge_hal_device_t*)devh)->upper_layer_info;
695a23fd118Syl150051 }
696a23fd118Syl150051 
697a23fd118Syl150051 /**
698a23fd118Syl150051  * xge_hal_device_from_private - Get HAL device object from private.
699a23fd118Syl150051  * @info_ptr: ULD context.
700a23fd118Syl150051  *
701a23fd118Syl150051  * Use ULD context to get HAL device.
702a23fd118Syl150051  *
703a23fd118Syl150051  * Returns:  Device handle.
704a23fd118Syl150051  *
705a23fd118Syl150051  * See also: xge_hal_device_private(), xge_hal_device_private_set()
706a23fd118Syl150051  */
707a23fd118Syl150051 static inline xge_hal_device_h
xge_hal_device_from_private(void * info_ptr)708a23fd118Syl150051 xge_hal_device_from_private(void *info_ptr)
709a23fd118Syl150051 {
7107eced415Sxw161283 	return xge_container_of((void ** ) info_ptr, xge_hal_device_t,
711a23fd118Syl150051 	upper_layer_info);
712a23fd118Syl150051 }
713a23fd118Syl150051 
714a23fd118Syl150051 /**
715a23fd118Syl150051  * xge_hal_device_mtu_check - check MTU value for ranges
716a23fd118Syl150051  * @hldev: the device
717a23fd118Syl150051  * @new_mtu: new MTU value to check
718a23fd118Syl150051  *
719a23fd118Syl150051  * Will do sanity check for new MTU value.
720a23fd118Syl150051  *
721a23fd118Syl150051  * Returns: XGE_HAL_OK - success.
722a23fd118Syl150051  * XGE_HAL_ERR_INVALID_MTU_SIZE - MTU is invalid.
723a23fd118Syl150051  *
724a23fd118Syl150051  * See also: xge_hal_device_mtu_set()
725a23fd118Syl150051  */
726a23fd118Syl150051 static inline xge_hal_status_e
xge_hal_device_mtu_check(xge_hal_device_t * hldev,int new_mtu)727a23fd118Syl150051 xge_hal_device_mtu_check(xge_hal_device_t *hldev, int new_mtu)
728a23fd118Syl150051 {
729a23fd118Syl150051 	if ((new_mtu < XGE_HAL_MIN_MTU) || (new_mtu > XGE_HAL_MAX_MTU)) {
730a23fd118Syl150051 		return XGE_HAL_ERR_INVALID_MTU_SIZE;
731a23fd118Syl150051 	}
732a23fd118Syl150051 
733a23fd118Syl150051 	return XGE_HAL_OK;
734a23fd118Syl150051 }
735a23fd118Syl150051 
736a23fd118Syl150051 void xge_hal_device_bcast_enable(xge_hal_device_h devh);
737a23fd118Syl150051 
738a23fd118Syl150051 void xge_hal_device_bcast_disable(xge_hal_device_h devh);
739a23fd118Syl150051 
740a23fd118Syl150051 void xge_hal_device_terminating(xge_hal_device_h devh);
741a23fd118Syl150051 
742a23fd118Syl150051 xge_hal_status_e xge_hal_device_initialize(xge_hal_device_t *hldev,
743a23fd118Syl150051 		xge_hal_device_attr_t *attr, xge_hal_device_config_t *config);
744a23fd118Syl150051 
745a23fd118Syl150051 void xge_hal_device_terminate(xge_hal_device_t *hldev);
746a23fd118Syl150051 
747a23fd118Syl150051 xge_hal_status_e xge_hal_device_reset(xge_hal_device_t *hldev);
748a23fd118Syl150051 
749a23fd118Syl150051 xge_hal_status_e xge_hal_device_macaddr_get(xge_hal_device_t *hldev,
750a23fd118Syl150051 		int index,  macaddr_t *macaddr);
751a23fd118Syl150051 
752a23fd118Syl150051 xge_hal_status_e xge_hal_device_macaddr_set(xge_hal_device_t *hldev,
753a23fd118Syl150051 		int index,  macaddr_t macaddr);
754a23fd118Syl150051 
7557eced415Sxw161283 xge_hal_status_e xge_hal_device_macaddr_clear(xge_hal_device_t *hldev,
7567eced415Sxw161283 		int index);
7577eced415Sxw161283 
758a23fd118Syl150051 int xge_hal_device_macaddr_find(xge_hal_device_t *hldev, macaddr_t wanted);
759a23fd118Syl150051 
760a23fd118Syl150051 xge_hal_status_e xge_hal_device_mtu_set(xge_hal_device_t *hldev, int new_mtu);
761a23fd118Syl150051 
762a23fd118Syl150051 xge_hal_status_e xge_hal_device_status(xge_hal_device_t *hldev, u64 *hw_status);
763a23fd118Syl150051 
764a23fd118Syl150051 void xge_hal_device_intr_enable(xge_hal_device_t *hldev);
765a23fd118Syl150051 
766a23fd118Syl150051 void xge_hal_device_intr_disable(xge_hal_device_t *hldev);
767a23fd118Syl150051 
768a23fd118Syl150051 xge_hal_status_e xge_hal_device_mcast_enable(xge_hal_device_t *hldev);
769a23fd118Syl150051 
770a23fd118Syl150051 xge_hal_status_e xge_hal_device_mcast_disable(xge_hal_device_t *hldev);
771a23fd118Syl150051 
772a23fd118Syl150051 void xge_hal_device_promisc_enable(xge_hal_device_t *hldev);
773a23fd118Syl150051 
774a23fd118Syl150051 void xge_hal_device_promisc_disable(xge_hal_device_t *hldev);
775a23fd118Syl150051 
776a23fd118Syl150051 xge_hal_status_e xge_hal_device_disable(xge_hal_device_t *hldev);
777a23fd118Syl150051 
778a23fd118Syl150051 xge_hal_status_e xge_hal_device_enable(xge_hal_device_t *hldev);
779a23fd118Syl150051 
780a23fd118Syl150051 xge_hal_status_e xge_hal_device_handle_tcode(xge_hal_channel_h channelh,
781a23fd118Syl150051 					     xge_hal_dtr_h dtrh,
782a23fd118Syl150051 					     u8 t_code);
783a23fd118Syl150051 
784a23fd118Syl150051 xge_hal_status_e xge_hal_device_link_state(xge_hal_device_h devh,
785a23fd118Syl150051 			xge_hal_device_link_state_e *ls);
786a23fd118Syl150051 
787a23fd118Syl150051 void xge_hal_device_sched_timer(xge_hal_device_h devh, int interval_us,
788a23fd118Syl150051 			int one_shot);
789a23fd118Syl150051 
790a23fd118Syl150051 void xge_hal_device_poll(xge_hal_device_h devh);
791a23fd118Syl150051 
792a23fd118Syl150051 xge_hal_card_e xge_hal_device_check_id(xge_hal_device_h devh);
793a23fd118Syl150051 
794a23fd118Syl150051 int xge_hal_device_is_slot_freeze(xge_hal_device_h devh);
795a23fd118Syl150051 
796*19397407SSherry Moore void xge_hal_device_quiesce(xge_hal_device_t *hldev, xge_hal_device_h devh);
797*19397407SSherry Moore 
798a23fd118Syl150051 xge_hal_status_e
799a23fd118Syl150051 xge_hal_device_pci_info_get(xge_hal_device_h devh, xge_hal_pci_mode_e *pci_mode,
800a23fd118Syl150051 			xge_hal_pci_bus_frequency_e *bus_frequency,
801a23fd118Syl150051 			xge_hal_pci_bus_width_e *bus_width);
802a23fd118Syl150051 
803a23fd118Syl150051 xge_hal_status_e
804a23fd118Syl150051 xge_hal_spdm_entry_add(xge_hal_device_h devh, xge_hal_ipaddr_t *src_ip,
805a23fd118Syl150051 			xge_hal_ipaddr_t *dst_ip, u16 l4_sp, u16 l4_dp,
806a23fd118Syl150051 			u8 is_tcp, u8 is_ipv4, u8 tgt_queue);
807a23fd118Syl150051 
808a23fd118Syl150051 xge_hal_status_e
809a23fd118Syl150051 xge_hal_spdm_entry_remove(xge_hal_device_h devh, xge_hal_ipaddr_t *src_ip,
810a23fd118Syl150051 			xge_hal_ipaddr_t *dst_ip, u16 l4_sp, u16 l4_dp,
811a23fd118Syl150051 			u8 is_tcp, u8 is_ipv4);
812a23fd118Syl150051 
8138347601bSyl150051 xge_hal_status_e
8148347601bSyl150051 xge_hal_device_rts_section_enable(xge_hal_device_h devh, int index);
8158347601bSyl150051 
816a23fd118Syl150051 int
817a23fd118Syl150051 xge_hal_device_is_closed (xge_hal_device_h devh);
818a23fd118Syl150051 
8197eced415Sxw161283 /* private functions, don't use them in ULD */
8208347601bSyl150051 
8217eced415Sxw161283 void __hal_serial_mem_write64(xge_hal_device_t *hldev, u64 value, u64 *reg);
8228347601bSyl150051 
8237eced415Sxw161283 u64 __hal_serial_mem_read64(xge_hal_device_t *hldev, u64 *reg);
8248347601bSyl150051 
8258347601bSyl150051 
826a23fd118Syl150051 /* Some function protoypes for MSI implementation. */
827a23fd118Syl150051 xge_hal_status_e
8287eced415Sxw161283 xge_hal_channel_msi_set (xge_hal_channel_h channelh, int msi,
8297eced415Sxw161283 			 u32 msg_val);
830a23fd118Syl150051 void
831a23fd118Syl150051 xge_hal_mask_msi(xge_hal_device_t *hldev);
8327eced415Sxw161283 
833a23fd118Syl150051 void
834a23fd118Syl150051 xge_hal_unmask_msi(xge_hal_channel_h channelh);
8357eced415Sxw161283 
836a23fd118Syl150051 xge_hal_status_e
837a23fd118Syl150051 xge_hal_channel_msix_set(xge_hal_channel_h channelh, int msix_idx);
838a23fd118Syl150051 
8397eced415Sxw161283 xge_hal_status_e
8407eced415Sxw161283 xge_hal_mask_msix(xge_hal_device_h devh, int msi_id);
8417eced415Sxw161283 
8427eced415Sxw161283 xge_hal_status_e
8437eced415Sxw161283 xge_hal_unmask_msix(xge_hal_device_h devh, int msi_id);
8447eced415Sxw161283 
8457eced415Sxw161283 #if defined(XGE_HAL_CONFIG_LRO)
8467eced415Sxw161283 xge_hal_status_e
8477eced415Sxw161283 xge_hal_lro_init(u32 lro_scale, xge_hal_device_t *hldev);
8487eced415Sxw161283 
8497eced415Sxw161283 void
8507eced415Sxw161283 xge_hal_lro_terminate(u32 lro_scale, xge_hal_device_t *hldev);
8517eced415Sxw161283 #endif
852a23fd118Syl150051 
853a23fd118Syl150051 #if defined(XGE_DEBUG_FP) && (XGE_DEBUG_FP & XGE_DEBUG_FP_DEVICE)
854a23fd118Syl150051 #define __HAL_STATIC_DEVICE
855a23fd118Syl150051 #define __HAL_INLINE_DEVICE
856a23fd118Syl150051 
857a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE int
858a23fd118Syl150051 xge_hal_device_rev(xge_hal_device_t *hldev);
859a23fd118Syl150051 
860a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
861a23fd118Syl150051 xge_hal_device_begin_irq(xge_hal_device_t *hldev, u64 *reason);
862a23fd118Syl150051 
863a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
864a23fd118Syl150051 xge_hal_device_clear_rx(xge_hal_device_t *hldev);
865a23fd118Syl150051 
866a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
867a23fd118Syl150051 xge_hal_device_clear_tx(xge_hal_device_t *hldev);
868a23fd118Syl150051 
869a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
870a23fd118Syl150051 xge_hal_device_continue_irq(xge_hal_device_t *hldev);
871a23fd118Syl150051 
872a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
873a23fd118Syl150051 xge_hal_device_handle_irq(xge_hal_device_t *hldev);
874a23fd118Syl150051 
875a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE char *
876a23fd118Syl150051 xge_hal_device_bar0(xge_hal_device_t *hldev);
877a23fd118Syl150051 
878a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE char *
879a23fd118Syl150051 xge_hal_device_isrbar0(xge_hal_device_t *hldev);
880a23fd118Syl150051 
881a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE char *
882a23fd118Syl150051 xge_hal_device_bar1(xge_hal_device_t *hldev);
883a23fd118Syl150051 
884a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
885a23fd118Syl150051 xge_hal_device_bar0_set(xge_hal_device_t *hldev, char *bar0);
886a23fd118Syl150051 
887a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
888a23fd118Syl150051 xge_hal_device_isrbar0_set(xge_hal_device_t *hldev, char *isrbar0);
889a23fd118Syl150051 
890a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
891a23fd118Syl150051 xge_hal_device_bar1_set(xge_hal_device_t *hldev, xge_hal_channel_h channelh,
892a23fd118Syl150051 		char *bar1);
893a23fd118Syl150051 
894a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
895a23fd118Syl150051 xge_hal_device_mask_tx(xge_hal_device_t *hldev);
896a23fd118Syl150051 
897a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
898a23fd118Syl150051 xge_hal_device_mask_rx(xge_hal_device_t *hldev);
899a23fd118Syl150051 
900a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
901a23fd118Syl150051 xge_hal_device_mask_all(xge_hal_device_t *hldev);
902a23fd118Syl150051 
903a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
904a23fd118Syl150051 xge_hal_device_unmask_tx(xge_hal_device_t *hldev);
905a23fd118Syl150051 
906a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
907a23fd118Syl150051 xge_hal_device_unmask_rx(xge_hal_device_t *hldev);
908a23fd118Syl150051 
909a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE void
910a23fd118Syl150051 xge_hal_device_unmask_all(xge_hal_device_t *hldev);
911a23fd118Syl150051 
912a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
9138347601bSyl150051 xge_hal_device_poll_tx_channels(xge_hal_device_t *hldev, int *got_tx);
914a23fd118Syl150051 
915a23fd118Syl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
9168347601bSyl150051 xge_hal_device_poll_rx_channels(xge_hal_device_t *hldev, int *got_rx);
9178347601bSyl150051 
9188347601bSyl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
9198347601bSyl150051 xge_hal_device_poll_rx_channel(xge_hal_channel_t *channel, int *got_rx);
9208347601bSyl150051 
9218347601bSyl150051 __HAL_STATIC_DEVICE __HAL_INLINE_DEVICE xge_hal_status_e
9228347601bSyl150051 xge_hal_device_poll_tx_channel(xge_hal_channel_t *channel, int *got_tx);
923a23fd118Syl150051 
924a23fd118Syl150051 #if defined (XGE_HAL_CONFIG_LRO)
925a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL u8
926a23fd118Syl150051 __hal_header_parse_token_u8(u8 *string,u16 offset);
927a23fd118Syl150051 
928a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL u16
929a23fd118Syl150051 __hal_header_parse_token_u16(u8 *string,u16 offset);
930a23fd118Syl150051 
931a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL u32
932a23fd118Syl150051 __hal_header_parse_token_u32(u8 *string,u16 offset);
933a23fd118Syl150051 
934a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void
935a23fd118Syl150051 __hal_header_update_u8(u8 *string, u16 offset, u8 val);
936a23fd118Syl150051 
937a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void
938a23fd118Syl150051 __hal_header_update_u16(u8 *string, u16 offset, u16 val);
939a23fd118Syl150051 
940a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void
941a23fd118Syl150051 __hal_header_update_u32(u8 *string, u16 offset, u32 val);
942a23fd118Syl150051 
943a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL u16
9448347601bSyl150051 __hal_tcp_seg_len(iplro_t *ip, tcplro_t *tcp);
945a23fd118Syl150051 
946a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9478347601bSyl150051 __hal_ip_lro_capable(iplro_t *ip, xge_hal_dtr_info_t *ext_info);
948a23fd118Syl150051 
949a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9508347601bSyl150051 __hal_tcp_lro_capable(iplro_t *ip, tcplro_t *tcp, lro_t *lro, int *ts_off);
951a23fd118Syl150051 
952a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9538347601bSyl150051 __hal_lro_capable(u8 *buffer, iplro_t **ip, tcplro_t **tcp,
9547eced415Sxw161283 		xge_hal_dtr_info_t *ext_info);
955a23fd118Syl150051 
956a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9577eced415Sxw161283 __hal_get_lro_session(u8 *eth_hdr, iplro_t *ip, tcplro_t *tcp, lro_t **lro,
9588347601bSyl150051 		xge_hal_dtr_info_t *ext_info, xge_hal_device_t *hldev,
9597eced415Sxw161283 		xge_hal_lro_desc_t *ring_lro, lro_t **lro_end3);
9608347601bSyl150051 
9618347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9628347601bSyl150051 __hal_lro_under_optimal_thresh(iplro_t *ip, tcplro_t *tcp, lro_t *lro,
963a23fd118Syl150051 		xge_hal_device_t *hldev);
964a23fd118Syl150051 
965a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9668347601bSyl150051 __hal_collapse_ip_hdr(iplro_t *ip, tcplro_t *tcp, lro_t *lro,
967a23fd118Syl150051 		xge_hal_device_t *hldev);
968a23fd118Syl150051 
969a23fd118Syl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9708347601bSyl150051 __hal_collapse_tcp_hdr(iplro_t *ip, tcplro_t *tcp, lro_t *lro,
9718347601bSyl150051 		xge_hal_device_t *hldev);
972a23fd118Syl150051 
9738347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9748347601bSyl150051 __hal_append_lro(iplro_t *ip, tcplro_t **tcp, u32 *seg_len, lro_t *lro,
9758347601bSyl150051 		xge_hal_device_t *hldev);
976a23fd118Syl150051 
9778347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9787eced415Sxw161283 xge_hal_lro_process_rx(int ring, u8 *eth_hdr, u8 *ip_hdr, tcplro_t **tcp,
9797eced415Sxw161283                        u32 *seglen, lro_t **p_lro,
9807eced415Sxw161283                        xge_hal_dtr_info_t *ext_info, xge_hal_device_t *hldev,
9817eced415Sxw161283                        lro_t **lro_end3);
9827eced415Sxw161283 
9837eced415Sxw161283 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
9848347601bSyl150051 xge_hal_accumulate_large_rx(u8 *buffer, tcplro_t **tcp, u32 *seglen,
9858347601bSyl150051 		lro_t **lro, xge_hal_dtr_info_t *ext_info,
9868347601bSyl150051 		xge_hal_device_t *hldev, lro_t **lro_end3);
987a23fd118Syl150051 
9887eced415Sxw161283 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL lro_t	*
9897eced415Sxw161283 xge_hal_lro_next_session (xge_hal_device_t *hldev, int ring);
9908347601bSyl150051 
9918347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL lro_t *
9928347601bSyl150051 xge_hal_lro_get_next_session(xge_hal_device_t *hldev);
9938347601bSyl150051 
9948347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL void
9958347601bSyl150051 __hal_open_lro_session (u8 *buffer, iplro_t *ip, tcplro_t *tcp, lro_t **lro,
9967eced415Sxw161283                         xge_hal_device_t *hldev, xge_hal_lro_desc_t *ring_lro,
9977eced415Sxw161283                         int slot, u32 tcp_seg_len, int ts_off);
9988347601bSyl150051 
9998347601bSyl150051 __HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL int
10007eced415Sxw161283 __hal_lro_get_free_slot (xge_hal_lro_desc_t	*ring_lro);
1001a23fd118Syl150051 #endif
1002a23fd118Syl150051 
1003a23fd118Syl150051 #else /* XGE_FASTPATH_EXTERN */
1004a23fd118Syl150051 #define __HAL_STATIC_DEVICE static
1005a23fd118Syl150051 #define __HAL_INLINE_DEVICE inline
1006a23fd118Syl150051 #include "xgehal-device-fp.c"
1007a23fd118Syl150051 #endif /* XGE_FASTPATH_INLINE */
1008a23fd118Syl150051 
10098347601bSyl150051 
10108347601bSyl150051 __EXTERN_END_DECLS
10118347601bSyl150051 
1012a23fd118Syl150051 #endif /* XGE_HAL_DEVICE_H */
1013