From 9c145a99f56aab2dd97858c2500e1f2eafdc0491 Mon Sep 17 00:00:00 2001 From: Kelvin Cao Date: Wed, 30 Aug 2023 08:03:22 -0700 Subject: [PATCH] lib: Add check of event support for gasops Not all events are supported by every gen/variant of the Switchtec firmware. To solve this, since Gen4, a new bit in each event header is introduced to indicate if an event is supported by the firmware. Add support of this bit in the gasops for sideband interfaces. --- inc/switchtec/registers.h | 1 + lib/platform/gasops.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inc/switchtec/registers.h b/inc/switchtec/registers.h index 1fdabc58..06383379 100644 --- a/inc/switchtec/registers.h +++ b/inc/switchtec/registers.h @@ -39,6 +39,7 @@ #define SWITCHTEC_EVENT_EN_CLI BIT(2) #define SWITCHTEC_EVENT_EN_IRQ BIT(3) #define SWITCHTEC_EVENT_FATAL BIT(4) +#define SWITCHTEC_EVENT_NOT_SUPP BIT(31) #ifdef MSVC #pragma warning(disable: 4201) diff --git a/lib/platform/gasops.c b/lib/platform/gasops.c index 4012301c..c4f11c27 100644 --- a/lib/platform/gasops.c +++ b/lib/platform/gasops.c @@ -468,6 +468,11 @@ static int event_ctl(struct switchtec_dev *dev, enum switchtec_event_id e, } hdr = __gas_read32(dev, reg); + if (hdr & SWITCHTEC_EVENT_NOT_SUPP) { + errno = ENOTSUP; + return -errno; + } + if (data) for (i = 0; i < 5; i++) data[i] = __gas_read32(dev, ®[i + 1]); @@ -518,7 +523,7 @@ int gasop_event_ctl(struct switchtec_dev *dev, enum switchtec_event_id e, for (index = 0; index < nr_idxs; index++) { ret = event_ctl(dev, e, index, flags, data); - if (ret < 0) + if (ret < 0 && ret != -ENOTSUP) return ret; } } else {