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