Skip to content

Feature/ssr pr1 foundation#149

Draft
mortewm wants to merge 2 commits into
masterfrom
feature/ssr-pr1-foundation
Draft

Feature/ssr pr1 foundation#149
mortewm wants to merge 2 commits into
masterfrom
feature/ssr-pr1-foundation

Conversation

@mortewm

@mortewm mortewm commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

This PR introduces the SSR foundation layer needed by the rest of the stack.

It adds the DSAP TX support for SSR payloads and the initial SSR core logic for
route learning and registration handling. The goal of this PR is to establish
the protocol primitives and internal bookkeeping without yet wiring SSR into the
main WPC send path.

  • add SSR TX request support in dsap
  • add SSR-related payload formats and constants
  • introduce the SSR core module and First-Hop Table support
  • handle SSR registration indications and internal dispatch flow
  • add unit tests for SSR routing/core behavior
  • add internal tests for registration handling

@mortewm mortewm requested a review from sgunes-wirepas April 17, 2026 09:39
Comment thread lib/wpc/ssr/fht.c Outdated
if (old[i].state != SLOT_OCCUPIED)
continue;
int found;
size_t pos = probe(t, old[i].node_id, &found);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it should always find it but should the found be initialized to 0 and then checked after probe() just in case?

Comment thread lib/wpc/ssr/fht.c
Comment thread lib/wpc/ssr/fht.c
return pos;
}
}
/* Should not happen with correct load-factor management. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Haven't fully understood the inner workings now but might be good to define some INVALID_SLOT (for (size_t) -1 above). Then if this function returns that value for some reason, it can be checked by the caller when *found is 0 to be extra safe.

Comment thread lib/wpc/ssr/fht.c
if (timestamp <= s->last_refresh)
return 0;
}
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If probe() can return some INVALID_SLOT, it can be checked here

Comment thread test/CMakeLists.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason to have several test executables, or just personal preference?

Comment thread lib/wpc/dsap.c

if (use_ssr && (hop_count > SSR_MAX_HOPS || hops == NULL))
{
return 6;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

returned 6 in the previous if statement is a hacky way to convey the "invalid param" error to the MQTT interface, for example if the backend sends a too large message.

In this case the error doesn't depend on the user input (backend); it happens if we have an invalid value in the table, and it comes from the sink. So I think it should be okay to print an error and return a negative value to indicate internal error.

Comment thread lib/wpc/ssr/ssr.c Outdated
return true;
}

void ssr_init(void)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be good to have this function return an error code so that WPC_initialize can fail as well.

@mortewm mortewm force-pushed the feature/ssr-pr1-foundation branch from a73abc2 to 2fd4cfe Compare May 6, 2026 14:43
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