npi_vir.c revision 6f45ec7b0b964c3be967c4880e8867ac1e7763a5
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <npi_vir.h>
/* One register only */
uint64_t pio_offset[] = {
};
const char *pio_name[] = {
"DEV_FUNC_SR_REG",
};
/* One register only */
uint64_t fzc_pio_offset[] = {
};
const char *fzc_pio_name[] = {
"MULTI_PART_CTL_REG",
"LDGITMRES_REG"
};
/* 64 sets */
};
const char *fzc_pio_dma_bind_name[] = {
"DMA_BIND_REG",
};
/* 69 logical devices */
};
const char *fzc_pio_ldgnum_name[] = {
"LDG_NUM_REG",
};
/* PIO_LDSV, 64 sets by 8192 bytes */
uint64_t pio_ldsv_offset[] = {
};
const char *pio_ldsv_name[] = {
"LDSV0_REG",
"LDSV1_REG",
"LDSV2_REG",
"LDGIMGN_REG"
};
/* PIO_IMASK0: 64 by 8192 */
uint64_t pio_imask0_offset[] = {
};
const char *pio_imask0_name[] = {
"LD_IM0_REG",
};
/* PIO_IMASK1: 5 by 8192 */
uint64_t pio_imask1_offset[] = {
};
const char *pio_imask1_name[] = {
"LD_IM1_REG"
};
/* SID: 64 by 8 */
uint64_t fzc_pio_sid_offset[] = {
};
const char *fzc_pio_sid_name[] = {
"SID_REG"
};
{
int num_regs, i;
"\nPIO FZC Common Register Dump\n"));
for (i = 0; i < num_regs; i++) {
value = 0;
"%s\t 0x%08llx \n",
pio_offset[i],
}
for (i = 0; i < num_regs; i++) {
"%s\t 0x%08llx \n",
fzc_pio_offset[i],
fzc_pio_name[i], value));
}
"\n PIO FZC Register Dump Done \n"));
return (NPI_SUCCESS);
}
{
"\nFZC PIO LDG Number Register Dump\n"));
for (i = 0; i < num_regs; i++) {
value = 0;
"Logical Device %d: 0x%08llx "
"%s\t 0x%08llx \n",
fzc_pio_ldgnum_name[i], value));
}
}
"\n FZC PIO LDG Register Dump Done \n"));
return (NPI_SUCCESS);
}
{
"\nLD Device State Vector Register Dump\n"));
for (i = 0; i < num_regs; i++) {
value = 0;
"LDG State: group %d: 0x%08llx "
"%s\t 0x%08llx \n",
pio_ldsv_name[i], value));
}
}
"\n FZC PIO LDG Register Dump Done \n"));
return (NPI_SUCCESS);
}
{
"\nLD Interrupt Mask Register Dump\n"));
for (i = 0; i < num_regs; i++) {
value = 0;
&value);
"LD Interrupt Mask %d: 0x%08llx "
"%s\t 0x%08llx \n",
pio_imask0_name[i], value));
}
}
for (i = 0; i < num_regs; i++) {
value = 0;
&value);
"LD Interrupt Mask %d: 0x%08llx "
"%s\t 0x%08llx \n",
pio_imask1_name[i], value));
}
}
"\n FZC PIO Logical Device Group Register Dump Done \n"));
return (NPI_SUCCESS);
}
{
"\nSystem Interrupt Data Register Dump\n"));
for (i = 0; i < num_regs; i++) {
value = 0;
&value);
"SID for group %d: 0x%08llx "
"%s\t 0x%08llx \n",
fzc_pio_sid_name[i], value));
}
}
"\n FZC PIO SID Register Dump Done \n"));
return (NPI_SUCCESS);
}
/*
* 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
*/
{
int status = NPI_SUCCESS;
/*
* After read, this bit is set to 1 by hardware.
* We own it if tas bit read as 0.
* Set the lock state to free if it is in reset state.
*/
/* reset state */
}
" npi_dev_func_sr_init"
" sr <0x%x>",
} else {
" npi_dev_func_sr_init"
" tas busy <0x%x>",
}
return (status);
}
/*
* 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
*/
{
int status = NPI_SUCCESS;
/*
* tas bit will be set to 1 by hardware.
* reset tas bit when we unlock the sr.
*/
switch (state) {
case NPI_DEV_SR_LOCK_ST_FREE:
/*
* set it to busy and our function id.
*/
break;
case NPI_DEV_SR_LOCK_ST_RESET:
" npi_dev_func_sr_lock_enter"
" reset state <0x%x>",
break;
case NPI_DEV_SR_LOCK_ST_BUSY:
" npi_dev_func_sr_lock_enter"
" busy <0x%x>",
break;
default:
" npi_dev_func_sr_lock_enter",
" invalid state",
break;
}
} else {
" npi_dev_func_sr_lock_enter",
}
return (status);
}
/*
* 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
*/
{
int status = NPI_SUCCESS;
} else {
" npi_dev_func_sr_lock_free"
" not owner <0x%x>",
}
} else {
" npi_dev_func_sr_lock_free",
" invalid tas state <0x%x>",
}
return (status);
}
/*
* 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:
*/
{
/*
* After read, this bit is set to 1 by hardware.
* We own it if tas bit read as 0.
*/
}
return (NPI_SUCCESS);
}
/*
* 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.
*
* Return:
* NPI_SUCCESS - If shared value get is complete successfully.
*
* Error:
*/
{
/*
* After read, this bit is set to 1 by hardware.
* We own it if tas bit read as 0.
*/
}
return (NPI_SUCCESS);
}
/*
* 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:
*/
{
/*
* After read, this bit is set to 1 by hardware.
* We own it if tas bit read as 0.
*/
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
int status;
if (status != NPI_SUCCESS) {
" npi_dev_func_sr_src_get_set_clear"
" unable to acquire lock:"
" status <0x%x>", status));
return (status);
}
return (npi_dev_func_sr_lock_free(handle));
}
/*
* 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
*/
{
int status = NPI_SUCCESS;
/* must be the owner */
} else {
" npi_dev_func_sr_sr_set_only"
" not owner <0x%x>",
}
return (status);
}
/*
* 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:
*/
{
} else {
/* Other function already owns it */
}
return (NPI_SUCCESS);
}
/*
* 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:
*/
{
}
return (NPI_SUCCESS);
}
/*
* 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:
*/
{
if (mpc) {
}
return (NPI_SUCCESS);
}
/*
* npi_fzc_mpc_get():
* This function is called to get the access mode.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS -
*
*/
{
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
*
*/
{
int status;
if (status) {
return (status);
}
if (status) {
return (status);
}
}
if (status) {
return (status);
}
}
}
}
return (status);
}
/*
* 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_set"
"ld <0x%x>", ld));
}
" npi_fzc_ldg_num_set"
" ldg <0x%x>", ldg));
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
" npi_fzc_ldg_num_get"
" Invalid Input:",
" ld <0x%x>", ld));
}
return (NPI_SUCCESS);
}
/*
* npi_ldsv_ldfs_get():
* This function is called to get device state vectors.
* Parameters:
* handle - NPI handle
* ldg - logical device group (0 - 63)
* *ldf_p - pointer to store ldf0 and ldf1 flag bits.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
{
int status;
return (status);
}
return (status);
}
return (status);
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
" npi_ldsv_get"
" Invalid Input "
" ldg <0x%x>", ldg));
}
switch (vector) {
case VECTOR0:
break;
case VECTOR1:
break;
case VECTOR2:
break;
default:
" npi_ldsv_get"
" Invalid Input: "
" ldsv type <0x%x>", vector));
}
return (NPI_SUCCESS);
}
/*
* 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_get"
" Invalid Input: "
" ldg <0x%x>", ldg));
}
" npi_ldsv_ld_get Invalid Input: "
" ld <9x%x>", ld));
" npi_ldsv_ld_get Invalid Input:"
" ld-vector2 <0x%x>", ld));
}
switch (vector) {
case VECTOR0:
break;
case VECTOR1:
break;
case VECTOR2:
default:
"ldsv", vector));
}
} else {
if (ldf_type) {
} else {
}
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
if (ld >= NXGE_MAC_LD_START) {
}
}
/*
* 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
*/
{
if (ld >= NXGE_MAC_LD_START) {
}
}
/*
* 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
*/
{
" npi_intr_mask_set ld", ld));
}
ldf_mask &= LD_IM0_MASK;
"npi_intr_mask_set: ld %d "
" offset 0x%0llx "
" mask 0x%x",
return (NPI_SUCCESS);
}
/*
* 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
*/
{
" npi_intr_mask_get ld", ld));
}
return (NPI_SUCCESS);
}
/*
* 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_set"
" Invalid Input: "
" ldg <0x%x>", ldg));
}
if (!LD_INTTIMER_VALID(timer)) {
" npi_intr_ldg_mgmt_set Invalid Input"
" timer <0x%x>", timer));
}
if (arm) {
} else {
}
" npi_intr_ldg_mgmt_set: ldg %d"
" reg offset 0x%x",
return (NPI_SUCCESS);
}
/*
* 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
*/
{
" npi_intr_ldg_mgmt_timer_get"
" Invalid Input: ldg <0x%x>", ldg));
}
" npi_intr_ldg_mgmt_timer_get: ldg %d"
" reg offset 0x%x",
return (NPI_SUCCESS);
}
/*
* 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_intr_ldg_mgmt_arm"
" Invalid Input: ldg <0x%x>",
ldg));
}
" npi_intr_ldg_mgmt_arm: ldg %d"
" reg offset 0x%x",
return (NPI_SUCCESS);
}
/*
* 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
*/
{
if (res > LDGTITMRES_RES_MASK) {
" npi_fzc_ldg_timer_res_set"
" Invalid Input: res <0x%x>",
res));
return (NPI_FAILURE | NPI_VIR_TM_RES_INVALID);
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
return (NPI_SUCCESS);
}
/*
* 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_set"
" Invalid Input: ldg <0x%x>",
}
" npi_fzc_sid_set"
" Invalid Input: func <0x%x>",
}
" npi_fzc_sid_set"
" Invalid Input: vector <0x%x>",
" invalid VECTOR: npi_fzc_sid_set(%d)",
return (NPI_FAILURE |
}
}
}
return (NPI_SUCCESS);
}
/*
* 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
*/
{
" npi_fzc_sid_get"
" Invalid Input: ldg <0x%x>",
}
} else {
}
return (NPI_SUCCESS);
}
/*
* npi_fzc_sys_err_mask_set():
*
* Parameters:
* handle - NPI handle
* mask - set bit mapped mask
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
{
return (NPI_SUCCESS);
}
/*
* npi_fzc_sys_err_stat_get():
* This function is called to get the system error stats.
*
* Parameters:
* handle - NPI handle
* err_stat - sys_err_stat structure to hold stats.
* Return:
* NPI_SUCCESS -
* Error:
* NPI_FAILURE
*/
{
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
/*
* npi_fzc_mpc_get():
* This function is called to get the access mode.
* Parameters:
* handle - NPI handle
* Return:
* NPI_SUCCESS -
*
*/
{
return (NPI_SUCCESS);
}