Skip to content

Commit

Permalink
lib: Add check of event support for gasops
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kelvin-cao committed Aug 30, 2023
1 parent fc53dc0 commit 9c145a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/switchtec/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion lib/platform/gasops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &reg[i + 1]);
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9c145a9

Please sign in to comment.