summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-core/interfaces
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@linux.intel.com>2020-01-07 21:40:08 +0300
committerJason M. Bills <jason.m.bills@linux.intel.com>2020-01-07 21:43:56 +0300
commit820013481a115100d5f8f22dc01aac8cc0363a23 (patch)
tree99cd46b66d5b9b97d38265d553f4fb60fee0d6a2 /meta-openbmc-mods/meta-common/recipes-core/interfaces
parent965a056096e5e043748da8766fa50cb7afedb608 (diff)
downloadopenbmc-820013481a115100d5f8f22dc01aac8cc0363a23.tar.xz
Update to internal 2020-01-07
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-core/interfaces')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch45
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/smbus.c89
-rw-r--r--meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp_git.bb4
3 files changed, 103 insertions, 35 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch
index e456c10ad..88da437fc 100644
--- a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch
+++ b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/0001-Smbus-changes-for-libmctp.patch
@@ -1,8 +1,9 @@
-From cb330f4bf1f519032ee50d60f473c28df7b772d8 Mon Sep 17 00:00:00 2001
+From 40303196d9f07b71042cd7ba87dcab6fdad29422 Mon Sep 17 00:00:00 2001
From: Nikhil Potade <nikhil.potade@linux.intel.com>
Date: Tue, 19 Feb 2019 14:16:20 +0800
-Subject: [PATCH] Smbus changes for libmctp
+Subject: [PATCH 1/1] Smbus changes for libmctp
+Signed-off-by: James Feist <james.feist@linux.intel.com>
---
CMakeLists.txt | 6 ++++--
core.c | 2 ++
@@ -16,7 +17,7 @@ index a5b1042..249b12b 100644
@@ -2,8 +2,9 @@ cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
add_definitions (-DMCTP_LOG_STDERR)
- add_definitions (-DMCTP_FILEIO)
+ add_definitions (-DMCTP_HAVE_FILEIO)
+add_definitions (-DMCTP_DEFAULT_ALLOC)
-add_library (libmctp STATIC alloc.c core.c log.c libmctp.h serial.c)
@@ -33,7 +34,7 @@ index a5b1042..249b12b 100644
+ include)
diff --git a/core.c b/core.c
-index b855ced..8be7407 100644
+index 61356e9..622bc5e 100644
--- a/core.c
+++ b/core.c
@@ -17,6 +17,7 @@
@@ -44,16 +45,16 @@ index b855ced..8be7407 100644
struct mctp_bus {
mctp_eid_t eid;
struct mctp_binding *binding;
-@@ -50,6 +51,7 @@ struct mctp {
- */
- struct mctp_msg_ctx msg_ctxs[16];
+@@ -56,6 +57,7 @@ struct mctp {
+ ROUTE_BRIDGE,
+ } route_policy;
};
+/* clang-format on */
#ifndef BUILD_ASSERT
#define BUILD_ASSERT(x) \
diff --git a/libmctp.h b/libmctp.h
-index f0633e3..cec7c00 100644
+index b36a943..4f211f9 100644
--- a/libmctp.h
+++ b/libmctp.h
@@ -15,6 +15,7 @@ extern "C" {
@@ -64,16 +65,15 @@ index f0633e3..cec7c00 100644
struct mctp_hdr {
uint8_t ver;
uint8_t dest;
-@@ -30,12 +31,47 @@ struct mctp_hdr {
+@@ -30,19 +31,56 @@ struct mctp_hdr {
#define MCTP_HDR_SEQ_MASK (0x3)
#define MCTP_HDR_TAG_SHIFT (0)
#define MCTP_HDR_TAG_MASK (0x7)
+/* clang-format on */
- /* Maximum size of *payload* data in a MCTP packet
- * @todo: dynamic sixing based on channel implementation.
- */
- #define MCTP_MTU 64
+ /* Baseline maximum size of a MCTP packet */
+ #define MCTP_BMTU_PAYLOAD 64
+ #define MCTP_BMTU (MCTP_BMTU_PAYLOAD + sizeof(struct mctp_hdr))
+#define MCTP_CONTROL_MESSAGE_TYPE 0x00
+
@@ -111,23 +111,18 @@ index f0633e3..cec7c00 100644
+
/* packet buffers */
- /* Allow a little space before the MCTP header in the packet, for bindings that
-@@ -46,12 +82,14 @@ struct mctp_hdr {
- #define MCTP_PKTBUF_SIZE (MCTP_PKTBUF_BINDING_PAD + \
- (sizeof(struct mctp_hdr) + MCTP_MTU))
-
+/* clang-format off */
struct mctp_pktbuf {
- unsigned char data[MCTP_PKTBUF_SIZE];
- uint8_t start, end;
- uint8_t mctp_hdr_off;
+ size_t start, end, size;
+ size_t mctp_hdr_off;
struct mctp_pktbuf *next;
+ unsigned char data[];
};
+/* clang-format on */
- struct mctp_pktbuf *mctp_pktbuf_alloc(uint8_t len);
- void mctp_pktbuf_free(struct mctp_pktbuf *pkt);
-@@ -85,6 +123,7 @@ int mctp_message_tx(struct mctp *mctp, mctp_eid_t eid,
+ struct mctp_binding;
+
+@@ -90,6 +128,7 @@ int mctp_message_tx(struct mctp *mctp, mctp_eid_t eid,
void *msg, size_t msg_len);
/* hardware bindings */
@@ -135,7 +130,7 @@ index f0633e3..cec7c00 100644
struct mctp_binding {
const char *name;
uint8_t version;
-@@ -93,6 +132,7 @@ struct mctp_binding {
+@@ -101,6 +140,7 @@ struct mctp_binding {
int (*tx)(struct mctp_binding *binding,
struct mctp_pktbuf *pkt);
};
diff --git a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/smbus.c b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/smbus.c
index d7c396444..bbdfe2aa4 100644
--- a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/smbus.c
+++ b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp/smbus.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <unistd.h>
-#ifdef MCTP_FILEIO
+#ifdef MCTP_HAVE_FILEIO
#include <fcntl.h>
#endif
@@ -197,7 +197,7 @@ static int mctp_binding_smbus_tx(struct mctp_binding *b,
return 0;
}
-#ifdef MCTP_FILEIO
+#ifdef MCTP_HAVE_FILEIO
int mctp_smbus_read(struct mctp_binding_smbus *smbus)
{
ssize_t len = 0;
@@ -251,7 +251,7 @@ int mctp_smbus_read(struct mctp_binding_smbus *smbus)
break;
}
- smbus->rx_pkt = mctp_pktbuf_alloc(0);
+ smbus->rx_pkt = mctp_pktbuf_alloc(&(smbus->binding), 0);
assert(smbus->rx_pkt);
if (mctp_pktbuf_push(smbus->rx_pkt, &smbus->rxbuf[sizeof(*hdr)],
@@ -264,7 +264,6 @@ int mctp_smbus_read(struct mctp_binding_smbus *smbus)
mctp_bus_rx(&(smbus->binding), smbus->rx_pkt);
- mctp_pktbuf_free(smbus->rx_pkt);
smbus->rx_pkt = NULL;
} while (0);
@@ -284,11 +283,84 @@ int mctp_smbus_get_in_fd(struct mctp_binding_smbus *smbus)
return smbus->in_fd;
}
+
+int mctp_smbus_set_in_fd(struct mctp_binding_smbus *smbus, int fd)
+{
+ smbus->in_fd = fd;
+}
+
+int mctp_smbus_set_out_fd(struct mctp_binding_smbus *smbus, int fd)
+{
+ smbus->out_fd = fd;
+}
+
int mctp_smbus_get_out_fd(struct mctp_binding_smbus *smbus)
{
return smbus->out_fd;
}
+int mctp_smbus_open_in_bus(struct mctp_binding_smbus *smbus, int in_bus)
+{
+ char filename[60];
+ size_t filename_size = 0;
+ char slave_mqueue[20];
+ size_t mqueue_size = 0;
+ int fd = 0;
+ size_t size = sizeof(filename);
+ int address_7_bit = MCTP_SOURCE_SLAVE_ADDRESS >> 1;
+ int ret = -1;
+
+ snprintf(filename, size,
+ "/sys/bus/i2c/devices/i2c-%d/%d-%04x/slave-mqueue", in_bus,
+ in_bus, (address_7_bit << 8) + address_7_bit);
+
+ ret = open(filename, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
+ if (ret >= 0) {
+ return ret;
+ }
+
+ // Device doesn't exist. Create it.
+ filename_size = sizeof(filename);
+ snprintf(filename, filename_size,
+ "/sys/bus/i2c/devices/i2c-%d/new_device", in_bus);
+ filename[filename_size - 1] = '\0';
+
+ fd = open(filename, O_WRONLY);
+ if (fd < 0) {
+ mctp_prerr("can't open root device %s: %m", filename);
+ return -1;
+ }
+
+ mqueue_size = sizeof(slave_mqueue);
+ snprintf(slave_mqueue, mqueue_size, "slave-mqueue %#04x",
+ (address_7_bit << 8) + address_7_bit);
+
+ size = write(fd, slave_mqueue, mqueue_size);
+ close(fd);
+ if (size != mqueue_size) {
+ mctp_prerr("can't create mqueue device on %s: %m", filename);
+ return -1;
+ }
+
+ size = sizeof(filename);
+ snprintf(filename, size,
+ "/sys/bus/i2c/devices/i2c-%d/%d-%04x/slave-mqueue", in_bus,
+ in_bus, (address_7_bit << 8) + address_7_bit);
+
+ return open(filename, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
+}
+
+int mctp_smbus_open_out_bus(struct mctp_binding_smbus *smbus, int out_bus)
+{
+ char filename[60];
+ size_t size = sizeof(filename);
+ snprintf(filename, size, "/dev/i2c-%d", out_bus);
+ filename[size - 1] = '\0';
+
+ return open(filename, O_RDWR | O_NONBLOCK);
+}
+
+/*
int mctp_smbus_open_bus(struct mctp_binding_smbus *smbus, int out_bus_num,
int root_bus_num)
{
@@ -359,13 +431,12 @@ int mctp_smbus_open_bus(struct mctp_binding_smbus *smbus, int out_bus_num,
return 0;
}
+*/
#endif
void mctp_smbus_register_bus(struct mctp_binding_smbus *smbus,
struct mctp *mctp, mctp_eid_t eid)
{
- assert(smbus->out_fd >= 0);
- assert(smbus->in_fd >= 0);
smbus->bus_id = mctp_register_bus(mctp, &smbus->binding, eid);
mctp_binding_set_tx_enabled(&smbus->binding, true);
}
@@ -375,19 +446,21 @@ struct mctp_binding_smbus *mctp_smbus_init(void)
struct mctp_binding_smbus *smbus;
smbus = __mctp_alloc(sizeof(*smbus));
+ memset(&(smbus->binding), 0, sizeof(smbus->binding));
+
smbus->in_fd = -1;
smbus->out_fd = -1;
smbus->rx_pkt = NULL;
smbus->binding.name = "smbus";
smbus->binding.version = 1;
+ smbus->binding.pkt_size = sizeof(smbus->rxbuf);
smbus->binding.tx = mctp_binding_smbus_tx;
-
return smbus;
}
void mctp_smbus_free(struct mctp_binding_smbus *smbus)
{
__mctp_free(smbus);
-} \ No newline at end of file
+}
diff --git a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp_git.bb b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp_git.bb
index fcf6631ea..132db31c7 100644
--- a/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp_git.bb
+++ b/meta-openbmc-mods/meta-common/recipes-core/interfaces/libmctp_git.bb
@@ -2,7 +2,7 @@ SUMMARY = "libmctp"
DESCRIPTION = "Implementation of MCTP (DTMF DSP0236)"
SRC_URI = "git://github.com/openbmc/libmctp.git"
-SRCREV = "62d7236f6be8e830e753c94b6b9018004a7f8e27"
+SRCREV = "34b9b3d82b049610775aea4460ff0f3bb9f02b1d"
PV = "0.1+git${SRCPV}"
@@ -37,4 +37,4 @@ CFLAGS_append = " -I ${STAGING_KERNEL_DIR}/include"
CXXFLAGS_append = " -I ${STAGING_KERNEL_DIR}/include/uapi"
CXXFLAGS_append = " -I ${STAGING_KERNEL_DIR}/include"
-do_configure[depends] += "virtual/kernel:do_shared_workdir" \ No newline at end of file
+do_configure[depends] += "virtual/kernel:do_shared_workdir"