Skip to content

Commit

Permalink
Grab GPU sensor data from MRW
Browse files Browse the repository at this point in the history
Need to add GPU sensors to processor targets so they can be marked
present or called out by OCC/HTMGT.
(gpu_func_sensor, gpu_temp_sensor, and memory_temp_sensor)

Adding these sensors as a GPU# indexed array to each processor.
The array consists of IMPI_SENSOR_NAME, IPMI_SENSOR_ID for each sensor
+ a bitwise OBUS_CONFIG. OBUS_CONFIG is needed to tell if this GPU is
present or not for this particular backing board identified by
the OBUS_CONFIG.

Example bitwise OBUS_CONFIG
0x06 = 0b0110 -> OBUS_CONFIG Both 0x01 and 0x02 include this GPU
0x04 = 0b0100 -> OBUS_CONFIG Only 0x02 includes this GPU

Depends-on: I8a0de390516fd02df07860b960db506899b13f14
Change-Id: Ib7a120e122546e2190c142dda23d88a25c416edf
RTC:178218
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/45222
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mderkse1 authored and dcrowell77 committed Sep 1, 2017
1 parent f9e0b48 commit 7b2191a
Showing 1 changed file with 147 additions and 1 deletion.
148 changes: 147 additions & 1 deletion src/usr/targeting/common/processMrw.pl
Expand Up @@ -105,6 +105,113 @@
"----------");

$targetObj->writeReport($str);

########################
## Used to setup GPU sensors on processors
my %G_gpu_sensors;
# key: obusslot target,
# value: (GPU#, Function, Temp, MemTemp IPMI name/ids,

my %G_slot_to_proc;
# key: obusslot string
# value: processor target string
#########################

# convert a number string into a bit-position number
# example: "0x02" --> 0b0100 = 4
sub numToBitPositionNum
{
my ($hexStr) = @_;

my $num = 0x0001;
my $newNum = $num << hex($hexStr);
return $newNum;
}
# Used to populate G_gpu_sensors hash of array references
#
# Each array reference will be composed of 3 sensors +
# board cfg ID which together makes up a GPU.
# - each sensor has a sensor type & entity ID + a sensor ID
# - board cfg is known as OBUS_CONFIG in mrw
# (each GPU can belong to 1 or more cfgs)
#
sub addSensorToGpuSensors
{
my ($name, $obusslot_str, $type, $entID, $sensorID) = @_;
my $GPU_SENSORS_FUNC_OFFSET = 0;
my $GPU_SENSORS_TEMP_OFFSET = 2;
my $GPU_SENSORS_MEM_TEMP_OFFSET = 4;
my $rSensorArray = $G_gpu_sensors{$obusslot_str};
unless ($rSensorArray) {
$rSensorArray = [ "0xFFFF","0xFF","0xFFFF","0xFF",
"0xFFFF","0xFF","0x00" ];
}
if ($name =~ m/Func/)
{
$rSensorArray->[$GPU_SENSORS_FUNC_OFFSET] =
sprintf("0x%02X%02X", oct($type), oct($entID));
$rSensorArray->[$GPU_SENSORS_FUNC_OFFSET+1] = $sensorID;
}
elsif($name =~ m/Memory_Temp/)
{
$rSensorArray->[$GPU_SENSORS_MEM_TEMP_OFFSET] =
sprintf("0x%02X%02X", oct($type), oct($entID));
$rSensorArray->[$GPU_SENSORS_MEM_TEMP_OFFSET+1] = $sensorID;
}
elsif($name =~ m/Temp/)
{
$rSensorArray->[$GPU_SENSORS_TEMP_OFFSET] =
sprintf("0x%02X%02X", oct($type), oct($entID));
$rSensorArray->[$GPU_SENSORS_TEMP_OFFSET+1] = $sensorID;
}
$G_gpu_sensors{$obusslot_str} = $rSensorArray;
}
# Populates the G_slot_to_proc hash and updates the cfgID in G_gpu_sensors
# This is how we map the obusslot to the GPU sensors
sub addObusCfgToGpuSensors
{
my ($obusslot_str, $proc_target, $cfg) = @_;
my $GPU_SENSORS_OBUS_CFG_OFFSET = 6;
my $foundSlot = 0;
$G_slot_to_proc{$obusslot_str} = $proc_target;
foreach my $obusslot (keys %G_gpu_sensors)
{
if ($obusslot =~ m/$obusslot_str/)
{
# Add in the cfg number
my $rSensorArray = $G_gpu_sensors{$obusslot_str};
$rSensorArray->[$GPU_SENSORS_OBUS_CFG_OFFSET] =
sprintf("0x%02X",
(oct($rSensorArray->[$GPU_SENSORS_OBUS_CFG_OFFSET]) |
oct(numToBitPositionNum($cfg))) );
$foundSlot = 1;
last;
}
}
if (!$foundSlot)
{
print STDOUT sprintf("%s:%d ", __FILE__,__LINE__);
print STDOUT "Found obus slot ($obusslot_str - processor $proc_target)".
" not in G_gpu_sensors hash\n";
my $cfg_bit_num = numToBitPositionNum($cfg);
$G_gpu_sensors{$obusslot_str} =
["0xFFFF","0xFF","0xFFFF","0xFF","0xFFFF",
"0xFF", sprintf("0x02X",oct($cfg_bit_num))];
}
}
#--------------------------------------------------
## loop through all targets and do stuff
foreach my $target (sort keys %{ $targetObj->getAllTargets() })
Expand Down Expand Up @@ -371,6 +478,12 @@ sub processIpmiSensors {
oct($sensor_evt), $sensor_id_str,$instance,$fru_id,
$huid,$target);
$targetObj->writeReport($str);
if ($name =~ /^GPU\d$/)
{
addSensorToGpuSensors($sensor_name, $target, $sensor_type,
$entity_id, $sensor_id_str);
}
}
}
for (my $i=@sensors;$i<16;$i++)
Expand Down Expand Up @@ -733,6 +846,27 @@ sub processProcessor
}
}
# Add GPU sensors to processor
my @aGpuSensors = ();
foreach my $obusslot (sort keys %G_gpu_sensors)
{
# find matching obusslot to processor
my $proc_target = $G_slot_to_proc{$obusslot};
# if a processor target is found and it is the same as this target
if ($proc_target && ($target =~ m/$proc_target/))
{
# Add this GPU's sensors to the processor's array of GPU sensors
push (@aGpuSensors, @{ $G_gpu_sensors{$obusslot} });
}
}
if (@aGpuSensors)
{
# add GPU_SENSORS to this processor target
$targetObj->setAttribute( $target, "GPU_SENSORS",
join(',', @aGpuSensors) );
}
# Add final I2C arrays to processor
my $size = scalar @engine;
my $engine_attr = $engine[0];
Expand Down Expand Up @@ -1123,6 +1257,18 @@ sub processObus
{
foreach my $obrick_conn (@{$obus->{CONN}})
{
if ($targetObj->isBusAttributeDefined($obrick,
$obrick_conn->{BUS_NUM}, "OBUS_CONFIG"))
{
my $cfg = $targetObj->getBusAttribute($obrick,
$obrick_conn->{BUS_NUM}, "OBUS_CONFIG");
my ($processor) =
$obrick_conn->{SOURCE_PARENT} =~
m#(^.*/proc_socket-\d)#;
addObusCfgToGpuSensors($obrick_conn->{DEST_PARENT},
$processor, $cfg);
}
$match = ($obrick_conn->{SOURCE} eq $obrick);
if ($match eq 1)
{
Expand All @@ -1143,7 +1289,7 @@ sub processObus
$targetObj->setAttribute($obrick, "OBUS_SLOT_INDEX", -1);
}
my $enum_val = $targetObj->getAttribute($obrick,"OPTICS_CONFIG_MODE");
if ( $enum_val =~ /NVLINK/i)
{
Expand Down

0 comments on commit 7b2191a

Please sign in to comment.