npi_vir.h revision 4496171313bed39e96f21bc2f9faf2868e267ae3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _NPI_VIR_H
#define _NPI_VIR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <npi.h>
#include <nxge_hw.h>
/*
* Virtualization and Logical devices NPI error codes
*/
#define FUNCID_INVALID PORT_INVALID
#define VIR_ID_SHIFT(n) (n << NPI_PORT_CHAN_SHIFT)
/*
* Errors codes of shared register functions.
*/
#define NPI_VIR_SR_INITIALIZED(n) (VIR_ID_SHIFT(n) | \
/*
* Error codes of muti-partition control register functions.
*/
/*
* Error codes of DMA binding functions.
*/
#define NPI_VIR_BD_FUNC_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_BD_REG_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_BD_ID_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_BD_TXDMA_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_BD_RXDMA_INVALID(n) (VIR_ID_SHIFT(n) | \
/*
* Error codes of logical devices and groups functions.
*/
#define NPI_VIR_LDSV_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_INTM_TM_INVALID(n) (VIR_ID_SHIFT(n) | \
#define NPI_VIR_SID_VEC_INVALID(n) (VIR_ID_SHIFT(n) | \
/*
* Bit definition ([15:0] of the shared register
* used by the driver as locking mechanism.
* [1:0] lock state (RESET, FREE, BUSY)
* [3:2] function ID (owner)
* [11:4] Implementation specific states
* [15:12] Individual function state
*/
#define NPI_DEV_SR_LOCK_ST_RESET 0
#define NPI_DEV_SR_LOCK_ST_FREE 1
#define NPI_DEV_SR_LOCK_ST_BUSY 2
#define NPI_DEV_SR_LOCK_ST_SHIFT 0
#define NPI_DEV_SR_LOCK_ST_MASK 0x03
#define NPI_DEV_SR_LOCK_FID_SHIFT 2
#define NPI_DEV_SR_LOCK_FID_MASK 0x0C
#define NPI_DEV_SR_IMPL_ST_SHIFT 4
#define NPI_DEV_SR_IMPL_ST_MASK 0xfff0
/*
* DMA channel binding definitions.
*/
{ \
status = NPI_SUCCESS; \
if (!TXDMA_FUNC_VALID(fn)) { \
} else if (!SUBREGION_VALID(rn)) { \
} else if (!VIR_PAGE_INDEX_VALID(id)) { \
} \
}
#define DMA_BIND_TX_VALIDATE(n, status) \
{ \
status = NPI_SUCCESS; \
if (!TXDMA_CHANNEL_VALID(n)) { \
} \
}
#define DMA_BIND_RX_VALIDATE(n, status) \
{ \
status = NPI_SUCCESS; \
if (!VRXDMA_CHANNEL_VALID(n)) { \
} \
}
#define DMA_BIND_STEP 8
/*
* NPI defined data structure to program the DMA binding register.
*/
typedef struct _fzc_dma_bind {
/*
* Logical device definitions.
*/
#define LD_NUM_STEP 8
#define LDG_NUM_STEP 8
#define LDSV_STEP 8192
#define LDSV_OFFSET_MASK(ld) \
(((ld < NXGE_MAC_LD_START) ? \
#define LDG_SID_STEP 8
typedef enum {
LDF0,
} ldf_type_t;
typedef enum {
} ldsv_type_t;
/*
* Definitions for the system interrupt data.
*/
typedef struct _fzc_sid {
} fzc_sid_t, *p_fzc_sid_t;
/*
* Virtualization and Interrupt Prototypes.
*/
/*
* npi_dev_func_sr_init():
* This function is called to initialize the device function
* shared register (set the software implementation lock
* state to FREE).
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS - If initialization is complete successfully.
* (set sr bits to free).
* Error:
* NPI_FAILURE
* VIR_TAS_BUSY
*/
/*
* npi_dev_func_sr_lock_enter():
* This function is called to lock the function shared register
* by setting the lock state to busy.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS - If the function id can own the lock.
*
* Error:
* NPI_FAILURE
* VIR_SR_RESET
* VIR_SR_BUSY
* VIR_SR_INVALID
* VIR_TAS_BUSY
*/
/*
* npi_dev_func_sr_lock_free():
* This function is called to free the function shared register
* by setting the lock state to free.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS - If the function id can free the lock.
*
* Error:
* NPI_FAILURE
* VIR_SR_NOTOWNER
* VIR_TAS_NOTREAD
*/
/*
* npi_dev_func_sr_funcid_get():
* This function is called to get the caller's function ID.
* (based on address bits [25:26] on read access.
* (After read, the TAS bit is always set to 1. Software needs
* to write 0 to clear.) This function will write 0 to clear
* the TAS bit if we own it.
* Parameters:
* handle - NPI handle
* funcid_p - pointer to store the function id.
* Return:
* NPI_SUCCESS - If get function id is complete successfully.
*
* Error:
*/
/*
* npi_dev_func_sr_sr_raw_get():
* This function is called to get the shared register value.
* (After read, the TAS bit is always set to 1. Software needs
* to write 0 to clear if we own it.)
*
* Parameters:
* handle - NPI handle
* sr_p - pointer to store the shared value of this register.
*
* Return:
* NPI_SUCCESS - If shared value get is complete successfully.
*
* Error:
*/
/*
* npi_dev_func_sr_sr_get():
* This function is called to get the shared register value.
* (After read, the TAS bit is always set to 1. Software needs
* to write 0 to clear if we own it.)
*
* Parameters:
* handle - NPI handle
* sr_p - pointer to store the shared value of this register.
* . this will get only non-lock, non-function id portion
* . of the register
*
*
* Return:
* NPI_SUCCESS - If shared value get is complete successfully.
*
* Error:
*/
/*
* npi_dev_func_sr_sr_get_set_clear():
* This function is called to set the shared register value.
* (Shared register must be read first. If tas bit is 0, then
* it implies that the software can proceed to set). After
* setting, tas bit will be cleared.
* Parameters:
* handle - NPI handle
* impl_sr - shared value to set (only the 8 bit
* implementation specific state info).
*
* Return:
* NPI_SUCCESS - If shared value is set successfully.
*
* Error:
* NPI_FAILURE
* VIR_TAS_BUSY
*/
uint16_t);
/*
* npi_dev_func_sr_sr_set_only():
* This function is called to only set the shared register value.
* Parameters:
* handle - NPI handle
* impl_sr - shared value to set.
*
* Return:
* NPI_SUCCESS - If shared value is set successfully.
*
* Error:
* NPI_FAILURE
* VIR_TAS_BUSY
*/
/*
* npi_dev_func_sr_busy():
* This function is called to see if we can own the device.
* It will not reset the tas bit.
* Parameters:
* handle - NPI handle
* busy_p - pointer to store busy flag.
* (B_TRUE: device is in use, B_FALSE: free).
* Return:
* NPI_SUCCESS - If tas bit is read successfully.
* Error:
*/
/*
* npi_dev_func_sr_tas_get():
* This function is called to get the tas bit
* (after read, this bit is always set to 1, software write 0
* to clear it).
*
* Parameters:
* handle - NPI handle
* tas_p - pointer to store the tas value
*
* Return:
* NPI_SUCCESS - If tas value get is complete successfully.
* Error:
*/
/*
* npi_fzc_mpc_set():
* This function is called to enable the write access
* to FZC region to function zero.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS -
* Error:
*/
/*
* npi_fzc_mpc_get():
* This function is called to get the access mode.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS -
*
*/
/*
* npi_fzc_dma_bind_set():
* This function is called to set DMA binding register.
* Parameters:
* handle - NPI handle
* dma_bind - NPI defined data structure that
* to set.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*
*/
/*
* npi_fzc_ldg_num_set():
* This function is called to set up a logical group number that
* a logical device belongs to.
* Parameters:
* handle - NPI handle
* ld - logical device number (0 - 68)
* ldg - logical device group number (0 - 63)
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*
*/
/*
* npi_fzc_ldg_num_get():
* This function is called to get the logical device group that
* a logical device belongs to.
* Parameters:
* handle - NPI handle
* ld - logical device number (0 - 68)
* *ldg_p - pointer to store its group number.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
uint8_t *);
/*
* npi_ldsv_get():
* This function is called to get device state vectors.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* ldf_type - either LDF0 (0) or LDF1 (1)
* vector - vector type (0, 1 or 2)
* *ldf_p - pointer to store its flag bits.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
uint64_t *);
/*
* npi_ldsv_ld_get():
* This function is called to get the flag bit value of a device.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* ld - logical device (0 - 68)
* ldf_type - either LDF0 (0) or LDF1 (1)
* vector - vector type (0, 1 or 2)
* *ldf_p - pointer to store its flag bits.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_ldsv_ld_ldf0_get():
* This function is called to get the ldf0 bit value of a device.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* ld - logical device (0 - 68)
* *ldf_p - pointer to store its flag bits.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
boolean_t *);
/*
* npi_ldsv_ld_ldf1_get():
* This function is called to get the ldf1 bit value of a device.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* ld - logical device (0 - 68)
* *ldf_p - pointer to store its flag bits.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
boolean_t *);
/*
* npi_intr_mask_set():
* This function is called to select the mask bits for both ldf0 and ldf1.
* Parameters:
* handle - NPI handle
* ld - logical device (0 - 68)
* ldf_mask - mask value to set (both ldf0 and ldf1).
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
uint8_t);
/*
* npi_intr_mask_get():
* This function is called to get the mask bits.
* Parameters:
* handle - NPI handle
* ld - logical device (0 - 68)
* ldf_mask - pointer to store mask bits info.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
uint8_t *);
/*
* npi_intr_ldg_mgmt_set():
* This function is called to set interrupt timer and arm bit.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* arm - B_TRUE (arm) B_FALSE (disable)
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_intr_ldg_mgmt_timer_get():
* This function is called to get the timer counter
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* timer_p - pointer to store the timer counter.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
uint8_t *);
/*
* npi_intr_ldg_mgmt_arm():
* This function is called to arm the group.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_fzc_ldg_timer_res_set():
* This function is called to set the timer resolution.
* Parameters:
* handle - NPI handle
* res - timer resolution (# of system clocks)
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_fzc_ldg_timer_res_get():
* This function is called to get the timer resolution.
* Parameters:
* handle - NPI handle
* res_p - pointer to store the timer resolution.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_fzc_sid_set():
* This function is called to set the system interrupt data.
* Parameters:
* handle - NPI handle
* ldg - logical group (0 - 63)
* sid - NPI defined data to set
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
/*
* npi_fzc_sid_get():
* This function is called to get the system interrupt data.
* Parameters:
* handle - NPI handle
* ldg - logical group (0 - 63)
* sid_p - NPI defined data to get
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
#ifdef __cplusplus
}
#endif
#endif /* _NPI_VIR_H */