Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

[DCS Patch 2/5] port dynamic channel selection from rdkb infrastructure #643

Conversation

itayx
Copy link
Collaborator

@itayx itayx commented Jan 6, 2020

The Dynamic Channel Selection as a feature can provide information on the supported channels which can be utilized by the management system to provide better availability and user experience.
#562

The Dynamic Channel Selection feature is divided into several pull request, this is the second out of 5
start review from 9db41a9

High Level Infastructure (Controller & yaml): Support for Channel Scan & DCS:

Changes in this PR include the following:

  • beerocks defines: enums for Channel Scan & DCS
  • yaml: beerocks_message_common: Add channel scan structures
  • yaml: beerocks_message_control: Add channel scan & DCS CMDUs
  • controller: node: Add channel scan structures
  • controller: db: Add channel scan DB methods

@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch 2 times, most recently from fd4c6ed to 894b852 Compare January 7, 2020 13:58
@itayx itayx marked this pull request as ready for review January 8, 2020 13:54
@kantera800 kantera800 changed the title Feature/port dynamic channel selection from rdkb infastructure [DCS Patch 2/5] port dynamic channel selection from rdkb infrastructure Jan 8, 2020
@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch from 894b852 to 81c8bd4 Compare January 8, 2020 14:19
common/beerocks/bcl/include/bcl/beerocks_defines.h Outdated Show resolved Hide resolved
common/beerocks/bcl/include/bcl/beerocks_defines.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
const bool single_scan)
{
auto n = get_node(mac);
static std::list<sChannelScanResultsElement> dummy_return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh this one is super ugly.
I prefer return std::list<sChannelScanResultsElement>(); instead everywhere.
Or you can return a shared_ptr instead of const reference and return nullptr instead of dummy_return.

Anything BUT dummy_return 👎

Copy link
Collaborator

Choose a reason for hiding this comment

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

return {} can work as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried that, when I do I get an error saying:

error: returning reference to temporary [-Werror=return-local-addr]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or you can return a shared_ptr instead of const reference and return nullptr instead of dummy_return.

This will be the only thing that works. But it's super-annoying, because it means the caller has to check for nullptr everywhere while it could just work with the empty set without problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or you can return a shared_ptr instead of const reference and return nullptr instead of dummy_return.

This will be the only thing that works. But it's super-annoying, because it means the caller has to check for nullptr everywhere while it could just work with the empty set without problem.

So you think the dummy_return should stay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for now it stays, if we decide to fix this later on we'll decide in #665

// Channel Scan
//
bool set_channel_scan_is_enabled(const std::string &mac, const bool enable);
bool get_channel_scan_is_enabled(const std::string &mac);
Copy link
Collaborator

Choose a reason for hiding this comment

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

here and in any other method which doesn't change the state of the class, declare the function as const:

bool get_channel_scan_is_enabled(const std::string &mac) const;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also - the name is really long and for no reason. I prefer channel_scan_enabled(const std::string &mac) (nitpick)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So it will be

channel_scan_enabled(const std::string &mac) const; //get
channel_scan_enabled(const std::string &mac, const bool enable); //set

?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are far more important things to fix in this PR. So let's keep it for #665

controller/src/beerocks/master/db/db.h Show resolved Hide resolved
controller/src/beerocks/master/db/db.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/db.cpp Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/db.cpp Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/db.cpp Outdated Show resolved Hide resolved
const bool single_scan)
{
auto n = get_node(mac);
static std::list<sChannelScanResultsElement> dummy_return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

return {} can work as well

auto n = get_node(mac);
if (!n) {
LOG(ERROR) << "node not found.... ";
return *(std::make_shared<std::set<uint8_t>>());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work? AFAICS this has the same problem as return std::set<uint8_t>(); only the compiler doesn't complain about it...

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is basically creating a shared_ptr, then instead of returning the shared_ptr itself which would increment the reference count preventing the memory from being released, we return the contents and when we return they are invalid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a dummy_return, if we decide that using a dummy_return is incorrect we'll fix it in #665

Copy link
Collaborator

@tomereli tomereli left a comment

Choose a reason for hiding this comment

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

one small comment

@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch from 81c8bd4 to 7736ee5 Compare January 15, 2020 16:45
@kantera800
Copy link
Collaborator

ready for re-review:

  1. fixed all code review issues that not require push -f .
  2. clang format ran only from icsl.

Copy link
Collaborator

@tomereli tomereli left a comment

Choose a reason for hiding this comment

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

Please rebase-squash and I'll do the followup review.
@morantr please review after the rebase.

@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch 2 times, most recently from 5a2ee50 to 9202cba Compare January 16, 2020 12:51
@kantera800 kantera800 requested a review from tomereli January 16, 2020 12:54
@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch 4 times, most recently from 1e47869 to c971631 Compare January 16, 2020 13:48
@kantera800
Copy link
Collaborator

@kantera800 kantera800 force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch 3 times, most recently from b574c68 to 6a5042e Compare January 17, 2020 02:02
@ghost ghost assigned itayx Jan 17, 2020
Copy link
Collaborator

@tomereli tomereli left a comment

Choose a reason for hiding this comment

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

Small comments - but please fix them before merging. Especially everything related to the string to mac and mac to string conversions.

@@ -443,6 +447,30 @@ enum eBssType {
BSS_TYPE_INVALID
};

enum class eChannelScanErrCode : uint8_t {
CHANNEL_SCAN_SUCCESS = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its an enum class - no need for the CHANNEL_SCAN_ prefix. #665

};

enum class eChannelScanOpErrCode : uint8_t {
CHANNEL_SCAN_OP_SUCCESS = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/node.h Outdated Show resolved Hide resolved
controller/src/beerocks/master/db/db.cpp Outdated Show resolved Hide resolved
@kantera800 kantera800 self-requested a review January 19, 2020 12:23
@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch 2 times, most recently from d5defe5 to 43c37fc Compare January 19, 2020 14:52
itayx added 7 commits January 19, 2020 22:25
This is a preperative commit for 'Add channel scan structures'.

Add enums to support the DCS feature.
Add eChannelScanErrCode that describes the scan operation status.
Add eDcsOpErrCode that describes the API's operation status.

Signed-off-by: itay elenzweig <[email protected]>
This is a preperative commit for 'Add channel scan & DCS CMDUs'.

Add DCS structures to support the DCS feature [yaml only].

Signed-off-by: itay elenzweig <[email protected]>
This is a preperative commit for 'Add channel scan & DCS CMDUs'.

Add DCS structures to support the DCS feature [AutoGenerated].

Signed-off-by: itay elenzweig <[email protected]>
Add requests from the bml to the controller [YAML].
Add requests from the controller to the agent [YAML].
Add notifications from the agent to the controller [YAML].
Add requests from the agent to the monitor [YAML].
Add notifications from the monitor to the agent [YAML].

Signed-off-by: itay elenzweig <[email protected]>
Add requests from the bml to the controller [AutoGenerated].
Add requests from the controller to the agent [AutoGenerated].
Add notifications from the agent to the controller [AutoGenerated].
Add requests from the agent to the monitor [AutoGenerated].
Add notifications from the monitor to the agent [AutoGenerated].

Signed-off-by: itay elenzweig <[email protected]>
This is a preperative commit for 'Add channel scan DB methods'.

Add the result class & container, which is used to store
the DCS scan results returned from the monitor/agent.
Add DCS configutation class for the DCS feature.
Add DCS scan status class, which is used to
store the latest DCS scan results status.

Signed-off-by: itay elenzweig <[email protected]>
Add DB method get_hostap_by_mac
Add DB methods to get/set scan params (configutation).
Add DB methods to get/set scan status.
Add DB methods to get/set scan results.
Add DB methods to clear channel pool.
Add DB methods to check if a channel is in the
current channel scan's pool.

Signed-off-by: itay elenzweig <[email protected]>
@itayx itayx force-pushed the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch from 43c37fc to cd6b49c Compare January 19, 2020 20:26
@kantera800 kantera800 merged commit dde1672 into master Jan 20, 2020
@kantera800 kantera800 deleted the feature/port-dynamic-channel-selection-from-rdkb-infastructure branch January 20, 2020 10:00
@tomereli tomereli mentioned this pull request Jan 26, 2020
1 task
@itayx itayx mentioned this pull request Apr 28, 2020
16 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants