Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RACL] Add documentation and example config #26198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidschrammel
Copy link
Contributor

@davidschrammel davidschrammel commented Feb 10, 2025

This commit adds initial documentation for RACL and describes the racl configuration files in the form of inline examples.
Furthermore, it generates a racl_configuration.md file which documents the current RACL configuration for each module instance and interface.

I don't have a strong opinion on how to format the RACL config information in the generated tables. We can still discuss and changes this!

Note: This commit already mentions RACL ranges from #26094 that are not yet merged.

The Private CI errors ModuleNotFoundError: No module named 'reggen.md_helpers' are likely introduced in this commit, but I'm not sure how to fix them as I cannot reproduce them locally.

@davidschrammel davidschrammel marked this pull request as ready for review February 10, 2025 18:02
@davidschrammel davidschrammel removed the request for review from msfschaffner February 10, 2025 18:02
@davidschrammel davidschrammel force-pushed the racl-doc-1 branch 2 times, most recently from 8aebeae to 873e7a6 Compare February 11, 2025 16:09
util/raclgen.py Outdated Show resolved Hide resolved
util/raclgen.py Outdated Show resolved Hide resolved
@davidschrammel davidschrammel force-pushed the racl-doc-1 branch 4 times, most recently from af586d9 to 9f6cebf Compare February 11, 2025 17:14

Furthermore, each module instance that supports RACL must specify a valid `racl_mapping` for each of its `bus_interfaces`.
If there is only one such interface, a racl mapping may be specified as follows:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is there a reason to include the blank lines like this? I think that some tools might interpret this as a paragraph break, which we don't need around the code fragments. (Obviously, it would depend on the word processor or whatever, but we don't want "whereas" to be indented)

E.g., `racl_config: 'top_darjeeling/data/racl/racl.hjson'`.

Furthermore, each module instance that supports RACL must specify a valid `racl_mapping` for each of its `bus_interfaces`.
If there is only one such interface, a racl mapping may be specified as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd say "the racl mapping" to make it clear that there's only one in this case.

```hjson
racl_mappings: {
soc: 'top_darjeeling/data/racl/all_rd_wr_mapping.hjson'
sram: 'top_darjeeling/data/racl/all_rd_wr_mapping.hjson'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to give an example where the different interfaces have different mappings?


```hjson
{
error_response: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have documentation anywhere that explains what these keys mean? If not, maybe this file is the right place for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I have added some comments.

parser.add_argument('--racl-config',
'-r',
required=True,
required=not is_doc,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather clever! But the error messages might be a bit confusing. I'd probably make these optional for argparse, but then put an extra check just after the call to parse_args, which does something like this? (Completely untested!)

    if not args.is_doc:
        if (args.racl_config is None or
            args.ip is None or
            args.mapping is None):
          raise SystemExit("--racl-config, --ip and --mapping are all required for non-doc runs.")

Copy link
Contributor Author

@davidschrammel davidschrammel Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rswarbrick I pushed some changes and came up with a different solution. Let me know what you think of it!

% ./util/raclgen.py
usage: 
raclgen.py --doc DOC
    Generates markdown documentation of the RACL configuration for a given top.

raclgen.py --racl-config RACL_CONFIG --ip IP --mapping MAPPING [--if-name IF_NAME]
    Generates the RACL policy selection vector for the given IP, RACL mapping, and interface name.
              
raclgen.py: error: the following arguments are required: --racl-config/-r, --ip/-i, --mapping/-m

Arguably, this error message is still not 100% correct but I would like to avoid the if (args.racl_config ... checks.

for if_name, racl_mappings in module['racl_mappings'].items():
racl_mapping = {
'if_name': if_name,
'racl_group': racl_mappings['racl_group'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we already know that this key is valid for some reason? (An argument for using proper data types!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should probably add a proper serializer/class for the racl mappings and racl configuration. However, I would defer this to a future PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants