Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MojitOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
MojitOS
Commits
a0c1db32
Commit
a0c1db32
authored
2 years ago
by
ghuter
Browse files
Options
Downloads
Patches
Plain Diff
fix infiniband
parent
01fe5e1d
No related branches found
No related tags found
3 merge requests
!9
fix sensor example (doc)
,
!4
Amd, Tests, Doc, CI/CD
,
!3
Amd, tests, doc...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/infiniband.c
+56
-8
56 additions, 8 deletions
src/infiniband.c
src/infiniband.h
+4
-2
4 additions, 2 deletions
src/infiniband.h
with
60 additions
and
10 deletions
src/infiniband.c
+
56
−
8
View file @
a0c1db32
...
...
@@ -17,25 +17,44 @@
along with MojitO/S. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
#include
<stdlib.h>
#include
<fcntl.h>
#include
<stdio.h>
#include
<string.h>
#include
<glob.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
#include
"util.h"
#define NB_SENSOR 4
struct
Network
{
struct
Infiniband
{
uint64_t
values
[
NB_SENSOR
];
uint64_t
tmp_values
[
NB_SENSOR
];
int
sources
[
NB_SENSOR
];
};
typedef
struct
Network
Network
;
typedef
struct
Infiniband
Infiniband
;
unsigned
int
_get_infiniband
(
uint64_t
*
results
,
int
*
sources
)
{
if
(
sources
==
NULL
)
{
return
0
;
}
char
buffer
[
128
];
unsigned
int
_get_network
(
uint64_t
*
results
,
int
*
sources
);
for
(
int
i
=
0
;
i
<
NB_SENSOR
;
i
++
)
{
if
(
pread
(
sources
[
i
],
buffer
,
127
,
0
)
<
0
)
{
perror
(
"pread"
);
exit
(
1
);
}
results
[
i
]
=
strtoull
(
buffer
,
NULL
,
10
);
}
return
NB_SENSOR
;
}
unsigned
int
init_infiniband
(
char
*
infi_path
,
void
**
ptr
)
{
...
...
@@ -50,6 +69,7 @@ unsigned int init_infiniband(char *infi_path, void **ptr)
glob
(
"/sys/class/infiniband/*/ports/*/counters/"
,
0
,
NULL
,
&
res
);
if
(
res
.
gl_pathc
==
0
)
{
fprintf
(
stderr
,
"No infiniband found.
\n
"
);
return
0
;
}
...
...
@@ -62,7 +82,7 @@ unsigned int init_infiniband(char *infi_path, void **ptr)
"%s/port_xmit_data"
};
Network
*
state
=
malloc
(
sizeof
(
Network
));
Infiniband
*
state
=
malloc
(
sizeof
(
Infiniband
));
char
buffer
[
1024
];
for
(
int
i
=
0
;
i
<
NB_SENSOR
;
i
++
)
{
...
...
@@ -71,11 +91,39 @@ unsigned int init_infiniband(char *infi_path, void **ptr)
}
*
ptr
=
(
void
*
)
state
;
_get_
network
(
state
->
values
,
state
->
sources
);
_get_
infiniband
(
state
->
values
,
state
->
sources
);
return
NB_SENSOR
;
}
unsigned
int
get_infiniband
(
uint64_t
*
results
,
void
*
ptr
)
{
Infiniband
*
state
=
(
Infiniband
*
)
ptr
;
_get_infiniband
(
state
->
tmp_values
,
state
->
sources
);
for
(
int
i
=
0
;
i
<
NB_SENSOR
;
i
++
)
{
results
[
i
]
=
modulo_substraction
(
state
->
tmp_values
[
i
],
state
->
values
[
i
]);
}
memcpy
(
state
->
values
,
state
->
tmp_values
,
NB_SENSOR
*
sizeof
(
uint64_t
));
return
NB_SENSOR
;
}
void
clean_infiniband
(
void
*
ptr
)
{
Infiniband
*
state
=
(
Infiniband
*
)
ptr
;
if
(
state
==
NULL
)
{
return
;
}
for
(
int
i
=
0
;
i
<
NB_SENSOR
;
i
++
)
{
close
(
state
->
sources
[
i
]);
}
free
(
state
);
}
char
*
_labels_infiniband
[
NB_SENSOR
]
=
{
"irxp"
,
"irxb"
,
"itxp"
,
"itxb"
};
void
label_infiniband
(
char
**
labels
,
void
*
none
)
{
...
...
This diff is collapsed.
Click to expand it.
src/infiniband.h
+
4
−
2
View file @
a0c1db32
...
...
@@ -19,12 +19,14 @@
*******************************************************/
unsigned
int
init_infiniband
(
char
*
infi_path
,
void
**
ptr
);
unsigned
int
get_infiniband
(
uint64_t
*
results
,
void
*
ptr
);
void
clean_infiniband
(
void
*
ptr
);
void
label_infiniband
(
char
**
labels
,
void
*
);
Sensor
infiniband
=
{
.
init
=
init_infiniband
,
.
get
=
NULL
,
.
clean
=
NULL
,
.
get
=
get_infiniband
,
.
clean
=
clean_infiniband
,
.
label
=
label_infiniband
,
.
nb_opt
=
1
,
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment