-
Notifications
You must be signed in to change notification settings - Fork 693
[Buffer Manager][201911] Reclaim unused buffer for admin-down ports #1837
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5169953
Support handling port admin status in buffer manager
stephenxs 2e71aad
Add vstest for buffer manager
stephenxs 8797dc4
Address comments
stephenxs fd9e9d2
Fix review comments: reclaiming reserved buffer by removing lossless …
stephenxs f4a5cc3
Fix review comments
stephenxs 4c0b2df
Fix review comments by introducing two fvVectors for BUFFER_PG and BU…
stephenxs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import pytest | ||
| import time | ||
| from swsscommon import swsscommon | ||
|
|
||
| class TestBufferManager(object): | ||
| def make_dict(self, input_list): | ||
| return dict(input_list[1]) | ||
|
|
||
| def setup_db(self, dvs): | ||
| self.config_db = swsscommon.DBConnector(4, dvs.redis_sock, 0) | ||
| self.buffer_pg_table = swsscommon.Table(self.config_db, "BUFFER_PG") | ||
| self.port_table = swsscommon.Table(self.config_db, "PORT") | ||
| cable_length_table = swsscommon.Table(self.config_db, "CABLE_LENGTH") | ||
| cable_length_key = cable_length_table.getKeys()[0] | ||
| self.cable_lengths = self.make_dict(cable_length_table.get(cable_length_key)) | ||
| self.buffer_profile_table = swsscommon.Table(self.config_db, "BUFFER_PROFILE") | ||
|
|
||
| def load_pg_profile_lookup(self, dvs): | ||
| self.profile_lookup_info = {} | ||
| lines = dvs.runcmd('cat /usr/share/sonic/hwsku/pg_profile_lookup.ini')[1].split('\n') | ||
|
|
||
| SPEED = 0 | ||
| CABLE_LENGTH = 1 | ||
| SIZE = 2 | ||
| XON = 3 | ||
| XOFF = 4 | ||
| THRESHOLD = 5 | ||
| XON_OFFSET = 6 | ||
|
|
||
| for line in lines: | ||
| if len(line) == 0 or line[0] == '#': | ||
| continue | ||
| tokens = line.split() | ||
| self.profile_lookup_info[(tokens[SPEED], tokens[CABLE_LENGTH])] = { | ||
| 'size': tokens[SIZE], | ||
| 'xon': tokens[XON], | ||
| 'xoff': tokens[XOFF], | ||
| 'dynamic_th': tokens[THRESHOLD] | ||
| } | ||
| if XON_OFFSET < len(tokens): | ||
| self.profile_lookup_info[(tokens[SPEED], tokens[CABLE_LENGTH])]['xon_offset'] = tokens[XON_OFFSET] | ||
|
|
||
| def test_buffer_pg(self, dvs): | ||
| self.setup_db(dvs) | ||
|
|
||
| port = 'Ethernet0' | ||
| pg = port + '|3-4' | ||
|
|
||
| port_info = self.make_dict(self.port_table.get(port)) | ||
| if 'up' == port_info.get('admin_status'): | ||
| # By default, all ports should be admin down on VM. | ||
| # However, in case the port under test was admin up before the test, we just shut down it. | ||
| dvs.runcmd('config interface shutdown {}'.format(port)) | ||
| time.sleep(1) | ||
|
|
||
| # Make sure no lossless PG exists on an admin down port | ||
| assert not self.buffer_pg_table.get(pg)[0] | ||
neethajohn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| try: | ||
| # Startup the port. The lossless PG should be created according to speed and cable length | ||
| dvs.runcmd('config interface startup {}'.format(port)) | ||
|
|
||
| cable_length = self.cable_lengths.get(port) | ||
| speed = port_info.get('speed') | ||
|
|
||
| expected_profile_name = 'pg_lossless_{}_{}_profile'.format(speed, cable_length) | ||
| buffer_profile_info = self.make_dict(self.buffer_profile_table.get(expected_profile_name)) | ||
| buffer_pg_info = self.make_dict(self.buffer_pg_table.get(pg)) | ||
| assert buffer_pg_info['profile'] == '[BUFFER_PROFILE|{}]'.format(expected_profile_name) | ||
|
|
||
| self.load_pg_profile_lookup(dvs) | ||
| expected_profile_info = self.profile_lookup_info[(speed, cable_length)] | ||
| expected_profile_info['pool'] = '[BUFFER_POOL|ingress_lossless_pool]' | ||
| assert buffer_profile_info == expected_profile_info | ||
| finally: | ||
| # Shutdown the port. The lossless PG should be removed | ||
| dvs.runcmd('config interface shutdown {}'.format(port)) | ||
| time.sleep(1) | ||
| assert not self.buffer_pg_table.get(pg)[0] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.