Content-Type: multipart/mixed; boundary="===============5699108069532276112==" MIME-Version: 1.0 From: Ramesh Thomas Subject: [Accel-config] Re: [RFC] Provide library API to read and write raw sysfs attributes Date: Mon, 07 Feb 2022 13:34:06 -0800 Message-ID: <81a2c5c9-3c14-a430-28de-3d75683abd23@intel.com> In-Reply-To: c02ef4ab-a6fb-05d7-3236-be0367a3fb0e@intel.com To: accel-config@lists.01.org List-ID: --===============5699108069532276112== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 2/4/2022 3:26 PM, Dave Jiang wrote: > = > On 2/4/2022 2:03 PM, Ramesh Thomas wrote: >> On 2/4/2022 12:42 PM, Dave Jiang wrote: >>> >>> On 2/4/2022 12:15 PM, Ramesh Thomas wrote: >>>> I am thinking of providing some generic functions to read and write = >>>> sysfs attributes without much processing. This will be useful where = >>>> raw reads and writes are required e.g. listing values of attributes = >>>> or initializing attributes in a loop. This will open up = >>>> possibilities of advanced use cases where user can do custom batch = >>>> configurations in addition to the load and save configuration option. >>>> >>>> There will be a get and set function for devices, groups, wqs and = >>>> engines as follows >>>> >>>> /* structure to read and write attributes from sysfs */ >>>> struct accfg_sysfs_attr { >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char attr[MAX_PARAM_LEN]; >>>> }; >>>> >>>> int accfg_get_device_attr(struct accfg_device *device, const char = >>>> *attr_name, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct *accfg_sysfs_attr); >>>> int accfg_set_device_attr(struct accfg_device *device, const char = >>>> *attr_name, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct *accfg_sysfs_attr); >>>> >>>> int accfg_get_group_attr(struct accfg_group *group, const char = >>>> *attr_name, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct *accfg_sysfs_attr); >>>> int accfg_set_group_attr(struct accfg_group *group, const char = >>>> *attr_name, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 struct *accfg_sysfs_attr); >>>> >>> Does it provide additional processing on top of sysfs_read_attr() = >>> helper function? >> >> It creates the path from from device, wq, engine and group structure. = >> It will save last error (cmd_status) in accfg ctxt and return errors = >> returned from driver. Other than that it does not do any attribute = >> specific processing. > = > Ok by me from high level view if it makes the code cleaner. Unfortunately this will not work. The intention was to provide a generic = API to read/write sysfs attributes as strings. However since we cache = attributes in their respective types (int, long, string etc.), attribute = specific processing cannot be avoided. Maybe in future we could simplify things by not caching values in = private structures. I don't see a reason to cache them when that is done = in the sysfs and persisted in config files. We only need to validate = when user enters a value and load all of them in json as strings. > = > = >> >>> >>> >>>> similarly for wqs and engines. >>>> >>>> Let me know if you see any issue or other suggestions. >>>> >>>> Thanks, >>>> Ramesh >> --===============5699108069532276112==--