Message ID | 168149418140.4013891.18368466862769013304.stgit@djiang5-mobl3 |
---|---|
State | Superseded |
Headers | show |
Series | ndctl: Add support of QoS Throttling Group (QTG) id for CXL CLI | expand |
On Fri, Apr 14, 2023 at 10:43:01AM -0700, Dave Jiang wrote: > Add libcxl API to retrieve the QoS Throttling Group (QTG) ID for the root > decoder. Also add support to display the QTG ID for the root decoder > through the 'cxl list' command. > > Signed-off-by: Dave Jiang <dave.jiang@intel.com> > --- > cxl/json.c | 10 ++++++++++ > cxl/lib/libcxl.c | 11 +++++++++++ > cxl/lib/libcxl.sym | 1 + > cxl/lib/private.h | 1 + > cxl/libcxl.h | 3 +++ > 5 files changed, 26 insertions(+) > > diff --git a/cxl/json.c b/cxl/json.c > index e87bdd49a776..8dd65f942c6a 100644 > --- a/cxl/json.c > +++ b/cxl/json.c > @@ -760,6 +760,16 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, > jobj); > } > > + if (cxl_port_is_root(port)) { > + int qtg_id = cxl_decoder_get_qtg_id(decoder); > + > + if (qtg_id != CXL_QTG_ID_NONE) { > + jobj = json_object_new_int(qtg_id); > + if (jobj) > + json_object_object_add(jdecoder, "qtg_id", jobj); > + } > + } IIUC, - root decoders don't always have a valid qtg_id, and the field is omitted from the listing in that case. - memdev's (next patch) always have a valid (not -1) qtg_id. I guess it's customary, in cxl list, to not display empty fields. Well, that was my question and I think I answered it ;) Alison > + > json_object_set_userdata(jdecoder, decoder, NULL); > return jdecoder; > } > diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c > index 59e5bdbcc750..26985c9344b4 100644 > --- a/cxl/lib/libcxl.c > +++ b/cxl/lib/libcxl.c > @@ -1879,6 +1879,12 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base) > else > decoder->interleave_ways = strtoul(buf, NULL, 0); > > + sprintf(path, "%s/qtg_id", cxldecoder_base); > + if (sysfs_read_attr(ctx, path, buf) < 0) > + decoder->qtg_id = CXL_QTG_ID_NONE; > + else > + decoder->qtg_id = atoi(buf); > + > switch (port->type) { > case CXL_PORT_ENDPOINT: > sprintf(path, "%s/dpa_resource", cxldecoder_base); > @@ -2073,6 +2079,11 @@ CXL_EXPORT unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder) > return decoder->size; > } > > +CXL_EXPORT int cxl_decoder_get_qtg_id(struct cxl_decoder *decoder) > +{ > + return decoder->qtg_id; > +} > + > CXL_EXPORT unsigned long long > cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder) > { > diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym > index 1c6177c7dcae..d1c61f9252fe 100644 > --- a/cxl/lib/libcxl.sym > +++ b/cxl/lib/libcxl.sym > @@ -248,4 +248,5 @@ global: > cxl_region_get_mode; > cxl_decoder_create_ram_region; > cxl_region_get_daxctl_region; > + cxl_decoder_get_qtg_id; > } LIBCXL_4; > diff --git a/cxl/lib/private.h b/cxl/lib/private.h > index d648992b808d..ac6f111b5956 100644 > --- a/cxl/lib/private.h > +++ b/cxl/lib/private.h > @@ -126,6 +126,7 @@ struct cxl_decoder { > struct list_head targets; > struct list_head regions; > struct list_head stale_regions; > + int qtg_id; > }; > > enum cxl_decode_state { > diff --git a/cxl/libcxl.h b/cxl/libcxl.h > index 54d9f10537dd..66ce4a021c62 100644 > --- a/cxl/libcxl.h > +++ b/cxl/libcxl.h > @@ -135,6 +135,8 @@ struct cxl_dport *cxl_port_get_dport_by_memdev(struct cxl_port *port, > for (dport = cxl_dport_get_first(port); dport != NULL; \ > dport = cxl_dport_get_next(dport)) > > +#define CXL_QTG_ID_NONE -1 > + > struct cxl_decoder; > struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port); > struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder); > @@ -146,6 +148,7 @@ unsigned long long cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder); > unsigned long long cxl_decoder_get_dpa_size(struct cxl_decoder *decoder); > unsigned long long > cxl_decoder_get_max_available_extent(struct cxl_decoder *decoder); > +int cxl_decoder_get_qtg_id(struct cxl_decoder *decoder); > > enum cxl_decoder_mode { > CXL_DECODER_MODE_NONE, > >
diff --git a/cxl/json.c b/cxl/json.c index e87bdd49a776..8dd65f942c6a 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -760,6 +760,16 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder, jobj); } + if (cxl_port_is_root(port)) { + int qtg_id = cxl_decoder_get_qtg_id(decoder); + + if (qtg_id != CXL_QTG_ID_NONE) { + jobj = json_object_new_int(qtg_id); + if (jobj) + json_object_object_add(jdecoder, "qtg_id", jobj); + } + } + json_object_set_userdata(jdecoder, decoder, NULL); return jdecoder; } diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index 59e5bdbcc750..26985c9344b4 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -1879,6 +1879,12 @@ static void *add_cxl_decoder(void *parent, int id, const char *cxldecoder_base) else decoder->interleave_ways = strtoul(buf, NULL, 0); + sprintf(path, "%s/qtg_id", cxldecoder_base); + if (sysfs_read_attr(ctx, path, buf) < 0) + decoder->qtg_id = CXL_QTG_ID_NONE; + else + decoder->qtg_id = atoi(buf); + switch (port->type) { case CXL_PORT_ENDPOINT: sprintf(path, "%s/dpa_resource", cxldecoder_base); @@ -2073,6 +2079,11 @@ CXL_EXPORT unsigned long long cxl_decoder_get_size(struct cxl_decoder *decoder) return decoder->size; } +CXL_EXPORT int cxl_decoder_get_qtg_id(struct cxl_decoder *decoder) +{ + return decoder->qtg_id; +} + CXL_EXPORT unsigned long long cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder) { diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym index 1c6177c7dcae..d1c61f9252fe 100644 --- a/cxl/lib/libcxl.sym +++ b/cxl/lib/libcxl.sym @@ -248,4 +248,5 @@ global: cxl_region_get_mode; cxl_decoder_create_ram_region; cxl_region_get_daxctl_region; + cxl_decoder_get_qtg_id; } LIBCXL_4; diff --git a/cxl/lib/private.h b/cxl/lib/private.h index d648992b808d..ac6f111b5956 100644 --- a/cxl/lib/private.h +++ b/cxl/lib/private.h @@ -126,6 +126,7 @@ struct cxl_decoder { struct list_head targets; struct list_head regions; struct list_head stale_regions; + int qtg_id; }; enum cxl_decode_state { diff --git a/cxl/libcxl.h b/cxl/libcxl.h index 54d9f10537dd..66ce4a021c62 100644 --- a/cxl/libcxl.h +++ b/cxl/libcxl.h @@ -135,6 +135,8 @@ struct cxl_dport *cxl_port_get_dport_by_memdev(struct cxl_port *port, for (dport = cxl_dport_get_first(port); dport != NULL; \ dport = cxl_dport_get_next(dport)) +#define CXL_QTG_ID_NONE -1 + struct cxl_decoder; struct cxl_decoder *cxl_decoder_get_first(struct cxl_port *port); struct cxl_decoder *cxl_decoder_get_next(struct cxl_decoder *decoder); @@ -146,6 +148,7 @@ unsigned long long cxl_decoder_get_dpa_resource(struct cxl_decoder *decoder); unsigned long long cxl_decoder_get_dpa_size(struct cxl_decoder *decoder); unsigned long long cxl_decoder_get_max_available_extent(struct cxl_decoder *decoder); +int cxl_decoder_get_qtg_id(struct cxl_decoder *decoder); enum cxl_decoder_mode { CXL_DECODER_MODE_NONE,
Add libcxl API to retrieve the QoS Throttling Group (QTG) ID for the root decoder. Also add support to display the QTG ID for the root decoder through the 'cxl list' command. Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- cxl/json.c | 10 ++++++++++ cxl/lib/libcxl.c | 11 +++++++++++ cxl/lib/libcxl.sym | 1 + cxl/lib/private.h | 1 + cxl/libcxl.h | 3 +++ 5 files changed, 26 insertions(+)