mcdi_mon.c revision 49ef7e0638c8b771d8a136eae78b1c0f99acc8e0
/*
* Copyright (c) 2009-2015 Solarflare Communications Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the FreeBSD Project.
*/
#include "efx.h"
#include "efx_impl.h"
#define MCDI_MON_PAGE_SIZE 0x20
/* Bitmasks of valid port(s) for each sensor */
#define MCDI_MON_PORT_NONE (0x00)
#define MCDI_MON_PORT_P1 (0x01)
#define MCDI_MON_PORT_P2 (0x02)
#define MCDI_MON_PORT_P3 (0x04)
#define MCDI_MON_PORT_P4 (0x08)
#define MCDI_MON_PORT_Px (0xFFFF)
/* Entry for MCDI sensor in sensor map */
/* Entry for sensor next page flag in sensor map */
#define STAT_NEXT_PAGE() \
/* Placeholder for gaps in the array */
#define STAT_NO_SENSOR() \
/* Map from MC sensors to monitor statistics */
static const struct mcdi_sensor_map_s {
} mcdi_sensor_map[] = {
/* Sensor page 0 MC_CMD_SENSOR_xxx */
STAT_NEXT_PAGE(), /* 0x1f Next page flag (not a sensor) */
/* Sensor page 1 MC_CMD_SENSOR_xxx */
/* 0x38 CCOM_AVREG_1V2_SUPPLY_EXT_ADC */
/* 0x3a CCOM_AVREG_1V8_SUPPLY_EXT_ADC */
STAT_NO_SENSOR(), /* 0x3b (no sensor) */
STAT_NO_SENSOR(), /* 0x3c (no sensor) */
STAT_NO_SENSOR(), /* 0x3d (no sensor) */
STAT_NO_SENSOR(), /* 0x3e (no sensor) */
STAT_NEXT_PAGE(), /* 0x3f Next page flag (not a sensor) */
/* Sensor page 2 MC_CMD_SENSOR_xxx */
/* 0x43 MASTER_INTERNAL_TEMP_EXT_ADC */
/* 0x47 SLAVE_INTERNAL_TEMP_EXT_ADC */
STAT_NO_SENSOR(), /* 0x48 (no sensor) */
};
#define MCDI_STATIC_SENSOR_ASSERT(_field) \
== EFX_MON_STAT_STATE_ ## _field)
static void
{
/* Assert the MC_CMD_SENSOR and EFX_MON_STATE namespaces agree */
/*
* The MCDI sensor readings in the DMA buffer are a packed array of
* MC_CMD_SENSOR_VALUE_ENTRY structures, which only includes entries for
* supported sensors (bit set in sensor_mask). The sensor_mask and
* sensor readings do not include entries for the per-page NEXT_PAGE
* flag.
*
* sensor_mask may legitimately contain MCDI sensors that the driver
* does not understand.
*/
page++;
continue;
}
continue;
idx++;
continue;
/*
* stat_mask is a bitmask indexed by EFX_MON_* monitor statistic
* identifiers from efx_mon_stat_t (without NEXT_PAGE bits).
*
* If there is an entry in the MCDI sensor to monitor statistic
* map then the sensor reading is used for the value of the
* monitor statistic.
*/
/* Get MCDI sensor reading from DMA buffer */
/* Update EFX monitor stat from MCDI sensor reading */
}
}
if (stat_maskp != NULL) {
}
}
{
/* Hardware must support this MCDI sensor */
/* But we don't have to understand it */
goto fail1;
}
return (ENODEV);
return (0);
return (rc);
}
static __checkReturn efx_rc_t
{
}
static __checkReturn efx_rc_t
{
int page;
page = 0;
do {
goto fail1;
}
(1U << MC_CMD_SENSOR_PAGE0_NEXT));
return (0);
return (rc);
}
static __checkReturn efx_rc_t
{
goto fail1;
}
goto fail2;
}
}
goto fail3;
}
return (0);
return (rc);
}
{
goto fail1;
return (0);
return (rc);
}
{
#if EFSYS_OPT_SIENA
case EFX_FAMILY_SIENA:
break;
#endif
case EFX_FAMILY_HUNTINGTON:
break;
#endif
case EFX_FAMILY_MEDFORD:
break;
#endif
default:
goto fail1;
}
/* Get mc sensor mask size */
npages = 0;
goto fail2;
/* Allocate mc sensor mask */
goto fail3;
}
/* Read mc sensor mask */
npages)) != 0)
goto fail4;
/* Build monitor statistics mask */
return (0);
return (rc);
}
void
{
}
}
#endif /* EFSYS_OPT_MON_STATS */
#endif /* EFSYS_OPT_MON_MCDI */