From 0d4491cb4520e11eca129c44d3fe9d27109187dc Mon Sep 17 00:00:00 2001 From: Ben Widawsky Date: Fri, 31 Jul 2020 12:37:15 -0700 Subject: [PATCH] cxl: Rework caps to new function This will help upcoming caps Signed-off-by: Ben Widawsky Co-authored-by: Jaxon Haws Signed-off-by: Jaxon Haws --- ls-ecaps.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/ls-ecaps.c b/ls-ecaps.c index b080a19..432d95a 100644 --- a/ls-ecaps.c +++ b/ls-ecaps.c @@ -690,18 +690,12 @@ cap_rcec(struct device *d, int where) } static void -cap_dvsec_cxl(struct device *d, int id, int where) +dvsec_cxl_device(struct device *d, int where, int rev) { u16 w; - printf(": CXL\n"); - if (verbose < 2) - return; - - if (id != 0) - return; - - if (!config_fetch(d, where + PCI_CXL_CAP, PCI_CXL_DEV_LEN - PCI_CXL_CAP)) + /* Legacy 1.1 revs aren't handled */ + if (rev < 1) return; w = get_conf_word(d, where + PCI_CXL_CAP); @@ -719,6 +713,26 @@ cap_dvsec_cxl(struct device *d, int id, int where) printf("\t\tCXLSta:\tViral%c\n", FLAG(w, PCI_CXL_STATUS_VIRAL)); } +static void +cap_dvsec_cxl(struct device *d, int id, int where) +{ + u8 rev; + + printf(": CXL\n"); + if (verbose < 2) + return; + + if (id != 0) + return; + + rev = BITS(get_conf_byte(d, where + 0x6), 0, 4); + + if (!config_fetch(d, where, PCI_CXL_DEV_LEN)) + return; + + dvsec_cxl_device(d, where, rev); +} + static void cap_dvsec(struct device *d, int where) { -- 2.39.5