Skip to content

Commit

Permalink
Elbert: kcsd/ipmid support (#119)
Browse files Browse the repository at this point in the history
Summary:
Initial KCS/IPMI support for Elbert platform.

Changes:
- Adds KCS interface and LPC controller to elbert device tree
- Adds ipmid/kcsd/ipmitool to elbert config
- Adds initial pal and ipmid fru logic for elbert

## Testing

On BMC:

KCS/IPMI drivers loaded:
```
root@bmc-oob:~# dmesg | grep -i kcs
[   17.376002] aspeed-kcs-bmc: channel=2 addr=0xca8 idr=0x28 odr=0x34 str=0x40
[   17.376282] aspeed-kcs-bmc: channel=3 addr=0xca2 idr=0x2c odr=0x38 str=0x44

root@bmc-oob:~# dmesg | grep -i ipmi
[   17.375121] IPMI message handler: version 39.2
[   17.375188] ipmi device interface
[   17.375248] ipmi_si: IPMI System Interface driver
[   17.375437] ipmi_si: Unable to find any System Interface(s)
```

Write a SEL log to KCS on x86. On BMC, verify that log is received:
```
root@bmc-oob:~# grep -i ipmi /var/log/messages
 2020 Dec  1 18:00:44 bmc-oob. kern.info elbert-f07646ff5d-dirty: kernel: [   17.375121] IPMI message handler: version 39.2
 2020 Dec  1 18:00:44 bmc-oob. kern.info elbert-f07646ff5d-dirty: kernel: [   17.375188] ipmi device interface
 2020 Dec  1 18:00:44 bmc-oob. kern.info elbert-f07646ff5d-dirty: kernel: [   17.375248] ipmi_si: IPMI System Interface driver
 2020 Dec  1 18:00:44 bmc-oob. kern.warning elbert-f07646ff5d-dirty: kernel: [   17.375437] ipmi_si: Unable to find any System Interface(s)
 2020 Dec  1 18:00:44 bmc-oob. daemon.info elbert-f07646ff5d-dirty: kcsd: opened kcs device /dev/ipmi-kcs2, fd=4
 2020 Dec  1 18:00:44 bmc-oob. daemon.info elbert-f07646ff5d-dirty: kcsd: opened kcs device /dev/ipmi-kcs3, fd=4
 2020 Dec  1 18:01:24 bmc-oob. user.warning elbert-f07646ff5d-dirty: ipmid: SEL Entry, FRU: 1, Content: 00:00:02:74:F5:C6:5F:09:30:04:01:02:02:00:00:FF
 2020 Dec  1 18:01:24 bmc-oob. user.crit elbert-f07646ff5d-dirty: ipmid: SEL Entry: FRU: 1, Record: Standard (0x02), Time: 2020-12-01 18:01:24, Sensor: Unknown (0x02), Event Data: (0000FF) Unknown Assertion
```
```
root@bmc-oob:~# hexdump /mnt/data/sel1.bin
0000000 fbfb fbfb 0001 0000 0000 0000 0001 0000
0000010 f574 5fc6 f4d0 5fc6 0000 0000 0000 0000
0000020 0000 0000 0000 0000 0000 0000 0000 0000
*
0000100 0000 7402 c6f5 095f 0430 0201 0002 ff00
0000110 0001 3300 c6ba 005f 0000 0000 0000 0000
0000120 0002 3600 c6ba 005f 0000 0000 0000 0000
0000130 0003 3800 c6ba 005f 0000 0000 0000 0000
0000140 0004 5f02 c6f4 095f 0430 0201 0002 ff00
0000150 0000 0000 0000 0000 0000 0000 0000 0000
*
0000900
```

Get SEL logs:
```
root@bmc-oob:~# ipmitool -d 1 sel elist
   0 | 12/02/2020 | 02:01:24 | Temperature #0x02 | Transition to Idle | Asserted
```

Get SEL info:
```
root@bmc-oob:~# ipmitool -d 1 sel info
SEL Information
Version          : 1.5 (v1.5, v2 compliant)
Entries          : 1
Free Space       : 2032 bytes
Percent Used     : 0%
Last Add Time    : 12/02/2020 02:01:24
Last Del Time    : 12/02/2020 01:58:40
Overflow         : false
Supported Cmds   : 'Reserve'
```

Clear SEL logs:
```
oot@bmc-oob:~# ipmitool -d 1 sel clear
Clearing SEL.  Please allow a few seconds to erase.

root@bmc-oob:~# ipmitool -d 1 sel elist
SEL has no entries
```

Add new SEL logs:
```
root@bmc-oob:~# ipmitool -d 1 raw 0xa 0x44 0 0 0 0 0 01 00
 01 00
root@bmc-oob:~# ipmitool -d 1 raw 0xa 0x44 0 0 0 0 0 02 00
 02 00
root@bmc-oob:~# ipmitool -d 1 raw 0xa 0x44 0 0 0 0 0 03 00
 03 00

root@bmc-oob:~# ipmitool -d 1 sel elist
   0 | 12/02/2020 | 02:07:28 | reserved |  | Asserted
   1 | 12/02/2020 | 02:07:33 | reserved |  | Asserted
   2 | 12/02/2020 | 02:07:35 | reserved |  | Asserted
```

Check FRU:
```
root@bmc-oob:~# ipmitool fru
FRU Device Description : Builtin FRU Device (ID 0)
 Product Manufacturer  : Arista
 Product Name          : Elbert
 Product Part Number   : 7388
 Product Version       : 1
 Product Serial        : JAS001
 Product Asset Tag     : ASS001
```

Pull Request resolved: facebookexternal/openbmc.arista#119

Reviewed By: benwei13

fbshipit-source-id: 6faf4149e1
  • Loading branch information
joancaneus authored and facebook-github-bot committed Dec 9, 2020
1 parent 413b04b commit 6d660ed
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 0 deletions.
4 changes: 4 additions & 0 deletions meta-facebook/meta-elbert/conf/machine/elbert.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ PREFERRED_VERSION_libwatchdog = "0.2"
PREFERRED_VERSION_rest-api = "0.1"
PREFERRED_VERSION_fscd = "0.3"
PREFERRED_VERSION_libpal = "0.1"
PREFERRED_VERSION_libipmi = "0.2"
PREFERRED_VERSION_ipmid = "0.2"
PREFERRED_VERSION_openbmc-gpio = "0.2"
PREFERRED_VERSION_kcsd = "0.2"

MACHINE_FEATURES += "tpm2"
MACHINE_FEATURES += "emmc emmc-ext4"
Expand Down
3 changes: 3 additions & 0 deletions meta-facebook/meta-elbert/recipes-core/images/elbert-image.bb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ IMAGE_INSTALL += " \
usb-console \
wedge-eeprom \
weutil-dhcp-id \
kcsd \
ipmid \
ipmitool \
"
151 changes: 151 additions & 0 deletions meta-facebook/meta-elbert/recipes-elbert/ipmid/files/fruid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright 2020-present Facebook. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* Elbert specific FRUID related routine.
*/

#include "fruid.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <syslog.h>
#include <string.h>
#include <facebook/wedge_eeprom.h>

// ELBERT start //

#define WEDGE_FRUID_SIZE 0x100

#define COMMON_HDR_VER 1
#define PROD_INFO_VER 1
#define PROD_INFO_AREA_OFFSET 0x10
#define PROD_INFO_CKSUM_OFFSET ( PROD_INFO_AREA_OFFSET + 1 )
#define LANG_CODE_ENGLISH 25
#define TYPE_STR 0xC0
#define TYPE_LAST 0xC1
#define ZERO_CKSUM_CONST 0x100
#define LEN_BYTE_SIZE 8

typedef struct _fruid_common_hdr_t {
unsigned char ver;
unsigned char internal_use_area_offset;
unsigned char chassis_info_area_offset;
unsigned char board_info_area_offset;
unsigned char prod_info_area_offset;
unsigned char multi_record_area_offset;
unsigned char padding;
unsigned char cksum;
} fruid_common_hdr_t;

// Global structures
static unsigned char g_fruid[WEDGE_FRUID_SIZE] = {0};

// A macro to add an entry.
#define _APPEND_STR_VALUE( name ) do { \
if ( sizeof( name ) < 1 || i + 1 + sizeof( name ) >= sizeof( g_fruid ) ) { \
break; \
} \
g_fruid[i++] = TYPE_STR + sizeof( name ); \
memcpy( &g_fruid[i], name, sizeof( name ) ); \
i += sizeof( name ); \
} while( 0 )

// Main function to populate the fruid data structure, using the data
// from eeprom
static void populate_fruid( void ) {
struct wedge_eeprom_st eeprom;
// int rc = 0;
int len = 0;
int i = PROD_INFO_AREA_OFFSET;
unsigned char zero_val = 0x0;

fruid_common_hdr_t *chdr = ( fruid_common_hdr_t * )g_fruid;
memset( &g_fruid, sizeof( g_fruid ), zero_val );

chdr->ver = COMMON_HDR_VER;
chdr->prod_info_area_offset = PROD_INFO_AREA_OFFSET / LEN_BYTE_SIZE;
chdr->cksum = chdr->ver + chdr->prod_info_area_offset;
chdr->cksum = ZERO_CKSUM_CONST - chdr->cksum;

#if 0
rc = wedge_eeprom_parse( NULL, &eeprom );
if ( rc ) {
syslog( LOG_ALERT, "populate_fruid: wedge_eeprom_parse returns %d\n", rc );
return;
}
#endif
// ELBERTTODO: read contents from eeprom
strcpy( eeprom.fbw_system_manufacturer, "Arista" );
strcpy( eeprom.fbw_product_name, "Elbert" );
strcpy( eeprom.fbw_product_number, "7388" );
eeprom.fbw_product_version = 1;
strcpy( eeprom.fbw_product_serial, "JAS001" );
strcpy( eeprom.fbw_product_asset, "ASS001" );

g_fruid[i++] = PROD_INFO_VER;
g_fruid[i++] = 0x00;
g_fruid[i++] = LANG_CODE_ENGLISH;
_APPEND_STR_VALUE( eeprom.fbw_system_manufacturer );
_APPEND_STR_VALUE( eeprom.fbw_product_name );
_APPEND_STR_VALUE( eeprom.fbw_product_number );
char vbuf[5] = {0};
snprintf( vbuf, sizeof( vbuf ), "%0X", eeprom.fbw_product_version );
_APPEND_STR_VALUE( vbuf );
_APPEND_STR_VALUE( eeprom.fbw_product_serial );
_APPEND_STR_VALUE( eeprom.fbw_product_asset );
char fruid_file_name[] = "fruid_1.0";
_APPEND_STR_VALUE( fruid_file_name );
g_fruid[i++] = TYPE_LAST;

len = i - PROD_INFO_AREA_OFFSET + 1;
if ( len % LEN_BYTE_SIZE ) {
g_fruid[PROD_INFO_CKSUM_OFFSET] = len / LEN_BYTE_SIZE + 1;
i += LEN_BYTE_SIZE - ( len % LEN_BYTE_SIZE );
} else {
g_fruid[PROD_INFO_CKSUM_OFFSET] = len / LEN_BYTE_SIZE;
}

for ( int j = PROD_INFO_AREA_OFFSET; j < i; j++ ) {
g_fruid[i] += g_fruid[j];
}
g_fruid[i] = ZERO_CKSUM_CONST - g_fruid[i];

return;
}

int plat_fruid_size( unsigned char payload_id ) {
return WEDGE_FRUID_SIZE;
}

int plat_fruid_data( unsigned char payload_id, int fru_id, int offset, int count, unsigned char *data ) {
if ( ( offset + count ) > WEDGE_FRUID_SIZE ) {
return -1;
}
memcpy( data, &( g_fruid[offset] ), count );
return 0;
}

// ELBERT end //

// Initialize FRUID
int plat_fruid_init( void ) {
populate_fruid();
return 0;
}
24 changes: 24 additions & 0 deletions meta-facebook/meta-elbert/recipes-elbert/ipmid/files/lan.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2020-present Facebook. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "openbmc/ipmi.h"

void plat_lan_init( lan_config_t *lan )
{
return;
}
10 changes: 10 additions & 0 deletions meta-facebook/meta-elbert/recipes-elbert/ipmid/ipmid_0.2.bbappend
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LDFLAGS += " -lwedge_eeprom"
DEPENDS += "libwedge-eeprom libipmi obmc-pal update-rc.d-native"
RDEPENDS_${PN} += "libipmi libkv libwedge-eeprom"

IPMI_FEATURE_FLAGS = "-DSENSOR_DISCRETE_SEL_STATUS -DSENSOR_DISCRETE_WDT"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://fruid.c \
file://lan.c \
"
44 changes: 44 additions & 0 deletions meta-facebook/meta-elbert/recipes-elbert/platform-lib/files/pal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2020-present Facebook. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
* This file contains functions and logics that depends on Yamp specific
* hardware and kernel drivers. Here, some of the empty "default" functions
* are overridden with simple functions that returns non-zero error code.
* This is for preventing any potential escape of failures through the
* default functions that will return 0 no matter what.
*/

#include <stdio.h>
#include <string.h>
#include "pal.h"

// Elbert specific Platform Abstraction Layer (PAL) Functions
int
pal_get_platform_name( char *name ) {
// Return Elbert Specific value
strcpy( name, ELBERT_PLATFORM_NAME );
return 0;
}

int
pal_get_num_slots( uint8_t *num ) {
// Return Elbert Specific Value
*num = ELBERT_MAX_NUM_SLOTS;
return 0;
}
51 changes: 51 additions & 0 deletions meta-facebook/meta-elbert/recipes-elbert/platform-lib/files/pal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef FILES_PAL_H
#define FILES_PAL_H

/*
* Copyright 2020-present Facebook. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <openbmc/obmc-pal.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <openbmc/kv.h>
#include <openbmc/ipmi.h>
#include <stdbool.h>

#define MAX_NODES 2
#define MAX_NUM_FRUS 2

#define FRU_EEPROM "/sys/class/i2c-adapter/i2c-12/12-0050/eeprom"
#define PAGE_SIZE 0x1000

#define ELBERT_PLATFORM_NAME "elbert"
#define ELBERT_MAX_NUM_SLOTS 8

enum {
FRU_ALL = 0,
FRU_MB = 1,
};

#ifdef __cplusplus
} // extern "C"
#endif


#endif // FILES_PAL_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://pal.c \
file://pal.h \
"

DEPENDS += "libgpio libsensor-correction"
RDEPENDS_${PN} += "libgpio libsensor-correction"
LDFLAGS += " -lgpio -lsensor-correction"
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ CONFIG_JTAG=y
CONFIG_HAS_IOMEM=y
CONFIG_COMPILE_TEST=y
CONFIG_JTAG_ASPEED=y

#
# IPMI
#
CONFIG_IPMI_HANDLER=y
CONFIG_IPMI_PLAT_DATA=y
CONFIG_IPMI_SI=y
CONFIG_IPMI_DEVICE_INTERFACE=y

0 comments on commit 6d660ed

Please sign in to comment.