-
Notifications
You must be signed in to change notification settings - Fork 22
ON-16037: added functions to read stats for interfaces #52
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
Open
rdrinkwa-xilinx
wants to merge
1
commit into
Xilinx-CNS:master
Choose a base branch
from
rdrinkwa-xilinx:ON-16037
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* SPDX-License-Identifier: MIT */ | ||
| /* SPDX-FileCopyrightText: (c) Advanced Micro Devices, Inc. */ | ||
| /**************************************************************************\ | ||
| *//*! \file | ||
| ** \brief TCPDirect stats API | ||
| *//* | ||
| \**************************************************************************/ | ||
|
|
||
| #ifndef __ZF_STATS_H__ | ||
| #define __ZF_STATS_H__ | ||
|
|
||
| #ifndef __IN_ZF_TOP_H__ | ||
| # error "Please include zf.h to use TCPDirect." | ||
| #endif | ||
|
|
||
| #include <etherfabric/vi.h> | ||
|
|
||
| typedef ef_vi_stats_field_layout zf_stats_field_layout; | ||
| typedef ef_vi_stats_layout zf_stats_layout; | ||
|
|
||
| /*! \brief */ | ||
| typedef struct { | ||
| /** Number of underlying interfaces present in stack */ | ||
| int num_intfs; | ||
| /** Size of memory needed to query the stats in bytes */ | ||
| int total_data_size; | ||
| /** Array of layouts, one per interface */ | ||
| zf_stats_layout** layout; | ||
| } zf_interface_stats; | ||
|
|
||
| /*! \brief Allocate and retrieve layout for available statistics | ||
| ** | ||
| ** \param stack The stack to query. | ||
| ** \param collection Pointer to an zf_interface_stats, that is allocated and | ||
| ** updated on return with the layout for available | ||
| ** statistics. This must be released when no longer needed | ||
| ** using zf_stats_free_layout_collection(). | ||
| ** | ||
| ** \return Zero on success or negative error code. | ||
| ** | ||
| ** Retrieve layout for available statistics. | ||
| */ | ||
| ZF_LIBENTRY int | ||
| zf_stats_alloc_interface_stats(struct zf_stack* stack, | ||
| zf_interface_stats** collection); | ||
|
|
||
| /*! \brief Release the layout allocated by zf_stats_alloc_query_layout(). | ||
| ** | ||
| ** \param collection Pointer to an zf_interface_stats that was allocated | ||
| ** using zf_stats_alloc_layout_collection(). | ||
| */ | ||
| ZF_LIBENTRY void zf_stats_free_interface_stats(zf_interface_stats* collection); | ||
|
|
||
| /*! \brief Retrieve a set of statistic values | ||
| ** | ||
| ** \param stack The stack to query. | ||
| ** \param data Pointer to a buffer, into which the statistics are | ||
| ** retrieved. | ||
| ** The size of this buffer must be equal to the value of | ||
| ** total_data_size in the zf_interface_stats structure. | ||
| ** \param collection Pointer to a zf_interface_stats, that was allocated for | ||
| ** this stack by zf_stats_alloc_layout_collection. | ||
| ** \param do_reset True to reset the statistics after retrieving them. | ||
| ** | ||
| ** \return zero or a negative error code. | ||
| ** | ||
| ** Retrieve a set of statistic values. | ||
| ** | ||
| ** If do_reset is true, the statistics are reset after reading. | ||
| */ | ||
| ZF_LIBENTRY int zf_stats_query(struct zf_stack* stack, void* data, | ||
| zf_interface_stats* collection, | ||
| int do_reset); | ||
|
|
||
| #endif /* __ZF_STATS_H__ */ | ||
| /** @} */ |
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,68 @@ | ||
| /* SPDX-License-Identifier: MIT */ | ||
| /* SPDX-FileCopyrightText: (c) Advanced Micro Devices, Inc. */ | ||
| #include <zf_internal/zf_stack.h> | ||
|
|
||
| int | ||
| zf_stats_alloc_interface_stats(struct zf_stack* stack, | ||
| zf_interface_stats** collection) | ||
| { | ||
| int i, rc = 0; | ||
| int num_nics = stack->nics_n; | ||
| zf_interface_stats* c; | ||
|
|
||
| c = (zf_interface_stats*) malloc(sizeof(*c)); | ||
| if( c == NULL ) | ||
| return -ENOMEM; | ||
|
|
||
| c->layout = (zf_stats_layout**) malloc(sizeof(*c->layout) * num_nics); | ||
| if( c->layout == NULL ) { | ||
| free(c); | ||
| return -ENOMEM; | ||
| } | ||
| c->num_intfs = num_nics; | ||
| c->total_data_size = 0; | ||
|
|
||
| for( i = 0; i < num_nics && rc == 0; i++ ) { | ||
| ef_vi* vi = &stack->nic[i].vi; | ||
| rc = ef_vi_stats_query_layout(vi, | ||
| (const ef_vi_stats_layout** const) &c->layout[i]); | ||
| if( rc == 0 ) | ||
| c->total_data_size += c->layout[i]->evsl_data_size; | ||
| } | ||
|
|
||
|
|
||
| if( rc < 0 ) { | ||
| zf_stats_free_interface_stats(c); | ||
| return rc; | ||
| } | ||
| *collection = c; | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| void | ||
| zf_stats_free_interface_stats(zf_interface_stats* collection) | ||
| { | ||
| free(collection->layout); | ||
| free(collection); | ||
| } | ||
|
|
||
|
|
||
| int | ||
| zf_stats_query(struct zf_stack* stack, void* data, | ||
| zf_interface_stats* collection, int do_reset) | ||
| { | ||
| int i, rc = 0; | ||
| int num_intfs = stack->nics_n; | ||
| char* pData = (char*)data; | ||
|
|
||
| assert(num_intfs == collection->num_intfs); | ||
|
|
||
| for( i = 0; i < num_intfs && rc == 0; i++ ) { | ||
| ef_vi* vi = &stack->nic[i].vi; | ||
| rc = ef_vi_stats_query(vi, vi->dh, (void*)pData, do_reset); | ||
| pData += collection->layout[i]->evsl_data_size; | ||
| } | ||
|
|
||
| return rc; | ||
| } | ||
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
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.