4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_NXGE_NXGE_HIO_H
28 #define _SYS_NXGE_NXGE_HIO_H
36 #include <nxge_fflp.h>
37 #include <sys/mac_provider.h>
39 #define isLDOMservice(nxge) \
40 (nxge->environs == SOLARIS_SERVICE_DOMAIN)
41 #define isLDOMguest(nxge) \
42 (nxge->environs == SOLARIS_GUEST_DOMAIN)
43 #define isLDOMs(nxge) \
44 (isLDOMservice(nxge) || isLDOMguest(nxge))
46 #define NXGE_HIO_SHARE_MIN_CHANNELS 2
47 #define NXGE_HIO_SHARE_MAX_CHANNELS 2
49 /* ------------------------------------------------------------------ */
50 typedef uint8_t nx_rdc_t
;
51 typedef uint8_t nx_tdc_t
;
53 typedef uint64_t res_map_t
;
55 typedef uint64_t hv_rv_t
;
57 typedef hv_rv_t (*vr_assign
)(uint64_t, uint64_t, uint32_t *);
58 typedef hv_rv_t (*vr_unassign
)(uint32_t);
59 typedef hv_rv_t (*vr_getinfo
)(uint32_t, uint64_t *, uint64_t *);
61 /* HV 2.0 API group functions */
62 typedef hv_rv_t (*vr_cfgh_assign
)(uint64_t, uint64_t, uint64_t, uint32_t *);
63 typedef hv_rv_t (*vrlp_cfgh_conf
)(uint64_t, uint64_t, uint64_t, uint64_t,
65 typedef hv_rv_t (*vrlp_cfgh_info
)(uint64_t, uint64_t, uint64_t, uint64_t *,
70 vr_assign assign
; /* HV Major 1 interface */
71 vr_cfgh_assign cfgh_assign
; /* HV Major 2 interface */
76 typedef hv_rv_t (*vrlp_conf
)(uint64_t, uint64_t, uint64_t, uint64_t);
77 typedef hv_rv_t (*vrlp_info
)(uint64_t, uint64_t, uint64_t *, uint64_t *);
79 typedef hv_rv_t (*dc_assign
)(uint32_t, uint64_t, uint64_t *);
80 typedef hv_rv_t (*dc_unassign
)(uint32_t, uint64_t);
81 typedef hv_rv_t (*dc_getstate
)(uint32_t, uint64_t, uint64_t *);
82 typedef hv_rv_t (*dc_get_map
)(uint32_t, uint64_t *);
84 typedef hv_rv_t (*dc_getinfo
)(uint32_t, uint64_t, uint64_t *, uint64_t *);
92 vrlp_conf lp_conf
; /* HV Major 1 interface */
93 vrlp_info lp_info
; /* HV Major 1 interface */
94 vrlp_cfgh_conf lp_cfgh_conf
; /* HV Major 2 interface */
95 vrlp_cfgh_info lp_cfgh_info
; /* HV Major 2 interface */
106 /* ------------------------------------------------------------------ */
107 #define NXGE_VR_SR_MAX 8 /* There are 8 subregions (SR). */
110 NXGE_HIO_TYPE_SERVICE
= 0x80, /* We are a service domain driver. */
111 NXGE_HIO_TYPE_GUEST
/* We are a guest domain driver. */
116 FUNC0_VIR
= 0x1000000,
117 FUNC1_MNT
= 0x2000000,
118 FUNC1_VIR
= 0x3000000,
119 FUNC2_MNT
= 0x4000000,
120 FUNC2_VIR
= 0x5000000,
121 FUNC3_MNT
= 0x6000000,
122 FUNC3_VIR
= 0x7000000
125 #define VR_STEP 0x2000000
126 #define VR_VC_STEP 0x0004000
128 typedef enum { /* 0-8 */
157 #define VP_VC_OFFSET(channel) (channel << 10)
158 #define VP_RDC_OFFSET (1 << 9)
174 RX_DMA_ENT_MSK
= 0x68,
175 RX_DMA_CTL_STAT
= 0x70,
178 RX_DMA_CTL_STAT_DBG
= 0x98
191 Tx_RNG_ERR_LOGH
= 0x48,
192 Tx_RNG_ERR_LOGL
= 0x50,
193 TDMC_INTR_DBG
= 0x60,
199 * -------------------------------------------------------------
200 * These definitions are used to handle the virtual PIO_LDSV
202 * -------------------------------------------------------------
204 #define VLDG_OFFSET 0x2000
208 PIO_LDSV0
, /* ldf_0, 0-63 */
209 PIO_LDSV1
, /* ldf_1, 0-63 */
210 PIO_LDSV2
, /* ldf_0 & ldf_1, 64-69 */
211 PIO_LDGIMGN
/* arm/timer */
215 #define VR_INTR_BLOCK_SIZE 8
216 #define HIO_INTR_BLOCK_SIZE 4
218 /* ------------------------------------------------------------------ */
230 typedef struct nxge_hio_vr
{
233 uint32_t cookie
; /* The HV cookie. */
236 vr_region_t region
; /* 1 of 8 regions. */
238 int rdc_tbl
; /* 1 of 8 RDC tables. */
239 int tdc_tbl
; /* 1 of 8 TDC tables. */
240 ether_addr_t altmac
; /* The alternate MAC address. */
241 int slot
; /* According to nxge_m_mmac_add(). */
248 typedef nxge_status_t (*dc_init_t
)(nxge_t
*, int);
249 typedef void (*dc_uninit_t
)(nxge_t
*, int);
252 uint32_t number
; /* The LDG number assigned to this DC. */
253 uint64_t index
; /* Bits 7:5 of the (virtual) PIO_LDSV. */
255 uint64_t ldsv
; /* The logical device number */
256 uint64_t map
; /* Currently unused */
258 int vector
; /* The DDI vector number (index) */
262 * -------------------------------------------------------------
263 * The service domain driver makes use of both <index>, the index
264 * into a VR's virtual page, and <channel>, the absolute channel
265 * number, what we will call here the physical channel number.
267 * The guest domain will set both fields to the same value, since
268 * it doesn't know any better. And if a service domain owns a
269 * DMA channel, it will also set both fields to the same value,
270 * since it is not using a VR per se.
271 * -------------------------------------------------------------
273 typedef struct nx_dc
{
277 nxge_hio_vr_t
*vr
; /* The VR belonged to. */
279 vp_channel_t page
; /* VP_CHANNEL_0 - VP_CHANNEL_7 */
280 nxge_channel_t channel
; /* 1 of 16/24 channels */
282 * <channel> has its normal meaning. <page> refers to the
283 * virtual page of the VR that <channel> has been bound to.
284 * Therefore, in the service domain, <page> & <channel>
285 * are almost always different. While in a guest domain,
286 * they are always the same.
288 vpc_type_t type
; /* VP_BOUND_XX */
289 dc_init_t init
; /* nxge_init_xxdma_channel() */
290 dc_uninit_t uninit
; /* nxge_uninit_xxdma_channel() */
292 nxge_grp_t
*group
; /* The group belonged to. */
293 uint32_t cookie
; /* The HV cookie. */
296 boolean_t interrupting
; /* Interrupt enabled? */
301 nxge_hio_type_t type
;
309 /* vr[0] is reserved for the service domain. */
310 nxge_hio_vr_t vr
[NXGE_VR_SR_MAX
]; /* subregion map */
311 nxge_hio_dc_t rdc
[NXGE_MAX_RDCS
];
312 nxge_hio_dc_t tdc
[NXGE_MAX_TDCS
];
314 nx_rdc_tbl_t rdc_tbl
[NXGE_MAX_RDC_GROUPS
];
319 * -------------------------------------------------------------
321 * -------------------------------------------------------------
323 extern void nxge_get_environs(nxge_t
*);
324 extern int nxge_hio_init(nxge_t
*);
325 extern void nxge_hio_uninit(nxge_t
*);
327 extern int nxge_dci_map(nxge_t
*, vpc_type_t
, int);
330 * ---------------------------------------------------------------------
331 * These are the general-purpose DMA channel group functions. That is,
332 * these functions are used to manage groups of TDCs or RDCs in an HIO
335 * But is also expected that in the future they will be able to manage
337 * ---------------------------------------------------------------------
339 extern nxge_grp_t
*nxge_grp_add(nxge_t
*, nxge_grp_type_t
);
340 extern void nxge_grp_remove(nxge_t
*, nxge_grp_t
*);
341 extern int nxge_grp_dc_add(nxge_t
*, nxge_grp_t
*, vpc_type_t
, int);
342 extern void nxge_grp_dc_remove(nxge_t
*, vpc_type_t
, int);
343 extern nxge_hio_dc_t
*nxge_grp_dc_find(nxge_t
*, vpc_type_t
, int);
345 extern void nxge_delay(int);
346 extern const char *nxge_ddi_perror(int);
349 * ---------------------------------------------------------------------
350 * These are the Sun4v HIO function prototypes.
351 * ---------------------------------------------------------------------
353 extern void nxge_hio_group_get(void *arg
, mac_ring_type_t type
, int group
,
354 mac_group_info_t
*infop
, mac_group_handle_t ghdl
);
355 extern int nxge_hio_share_alloc(void *arg
, mac_share_handle_t
*shandle
);
356 extern void nxge_hio_share_free(mac_share_handle_t shandle
);
357 extern void nxge_hio_share_query(mac_share_handle_t shandle
,
358 mac_ring_type_t type
, mac_ring_handle_t
*rings
, uint_t
*n_rings
);
359 extern int nxge_hio_share_add_group(mac_share_handle_t
,
361 extern int nxge_hio_share_rem_group(mac_share_handle_t
,
363 extern int nxge_hio_share_bind(mac_share_handle_t
, uint64_t cookie
,
365 extern void nxge_hio_share_unbind(mac_share_handle_t
);
366 extern int nxge_hio_rxdma_bind_intr(nxge_t
*, rx_rcr_ring_t
*, int);
368 /* nxge_hio_guest.c */
369 extern void nxge_hio_unregister(nxge_t
*);
370 extern int nxge_hio_get_dc_htable_idx(nxge_t
*nxge
, vpc_type_t type
,
373 extern int nxge_guest_regs_map(nxge_t
*);
374 extern void nxge_guest_regs_map_free(nxge_t
*);
376 extern int nxge_hio_vr_add(nxge_t
*nxge
);
377 extern int nxge_hio_vr_release(nxge_t
*nxge
);
379 extern nxge_status_t
nxge_tdc_lp_conf(p_nxge_t
, int);
380 extern nxge_status_t
nxge_rdc_lp_conf(p_nxge_t
, int);
382 extern void nxge_hio_start_timer(nxge_t
*);
385 extern nxge_status_t
nxge_hio_intr_init(nxge_t
*);
386 extern void nxge_hio_intr_uninit(nxge_t
*);
388 extern nxge_status_t
nxge_intr_add(nxge_t
*, vpc_type_t
, int);
389 extern nxge_status_t
nxge_intr_remove(nxge_t
*, vpc_type_t
, int);
391 extern nxge_status_t
nxge_hio_intr_add(nxge_t
*, vpc_type_t
, int);
392 extern nxge_status_t
nxge_hio_intr_remove(nxge_t
*, vpc_type_t
, int);
394 extern nxge_status_t
nxge_hio_intr_add(nxge_t
*, vpc_type_t
, int);
395 extern nxge_status_t
nxge_hio_intr_rem(nxge_t
*, int);
397 extern int nxge_hio_ldsv_add(nxge_t
*, nxge_hio_dc_t
*);
399 extern void nxge_hio_ldsv_im(nxge_t
*, nxge_ldg_t
*, pio_ld_op_t
, uint64_t *);
400 extern void nxge_hio_ldgimgn(nxge_t
*, nxge_ldg_t
*);
403 extern void nxge_hio_hv_init(nxge_t
*);
406 extern int nxge_hio_hostinfo_get_rdc_table(p_nxge_t
);
407 extern int nxge_hio_hostinfo_init(nxge_t
*, nxge_hio_vr_t
*, ether_addr_t
*);
408 extern void nxge_hio_hostinfo_uninit(nxge_t
*, nxge_hio_vr_t
*);
414 #endif /* _SYS_NXGE_NXGE_HIO_H */