Skip to content

Osa enhancements#378

Merged
BenReed161 merged 3 commits into
Microsemi:masterfrom
BenReed161:osa-enhancements
May 20, 2026
Merged

Osa enhancements#378
BenReed161 merged 3 commits into
Microsemi:masterfrom
BenReed161:osa-enhancements

Conversation

@BenReed161
Copy link
Copy Markdown
Collaborator

No description provided.

allowed 1 hex char (max 0xf) but needs 2 for the 5-bit Gen6 mask (0x1f)
allowed 2 hex chars (max 0xff) but needs 3 for the 9-bit mask (0x1ff)
Fix alignment issue, previously Gen5 ended with newline so Gen6 was
forced to new line, removed so all gens remain on one line.

Pattern section was using the os_type link rate instead of the pattern
link rate.

Fixed logical AND which should be bitwise.
Comment thread cli/diag.c Outdated
if (cfg.os_types) {
ret = convert_hex_str(cfg.os_types, &os_type_mask,
&num_dwords, 1);
&num_dwords, 2);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm finding this code extremely difficult to understand. convert_hex_str() is weird. The documentation for os_types seems to indicate it just inputs a hex string like "0xA" with only 4 valid bits which should be really simple and shouldn't need a bunch of memory allocations and arrays of integers.

CFG_LONG already supports strings that have a 0x prefix so they can be specified in hexadecimal without all this extra work.

The documentation above for the command line parameter says there are only 4 bits in os_types. But this seems to be increasing it to take two hex characters (I assume). Then num_dwords is confusing because a d-word usually refers to something that is 4-bytes long or 8 hex characters.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi Logan, originally I used the convert_hex_str on a string of multiple dword hexadecimal values hence the allocating of arrays and such. But later down the line I also applied it to be used with regular hex values that weren't even dwords, without much thought as to easier solutions (as you mentioned). So I refactor the OSA functions which use convert_hex_str instead to use the default CFG_ args that have built-in 0x prefix handling. Some functions still use convert_hex_str but those are the original functions which needed it for multiple dwords in a string.
Hope that clears it up a little.
Thanks

convert_hex_str was being used too much throughout the code, allocated/
freeing memory unnecessarily.
Replace hex string argument with default int argument.
Copy link
Copy Markdown
Collaborator

@lsgunth lsgunth left a comment

Choose a reason for hiding this comment

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

That makes more sense, thanks!

@BenReed161 BenReed161 merged commit f4e17fe into Microsemi:master May 20, 2026
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.

2 participants