[Linuxptp-devel] [PATCH 1/1] Ensure TLV_PORT_STATS_NP statistics uses little endian.
As machine byte order may vary. Ensure TLV_PORT_STATS_NP statistics use defined order. As most of us use little endian hardware and to retain backward compatible with most of us, we decide to use little endian for the statistics. All other TLVs messages remain in network order. Signed-off-by: Erez Geva --- tlv.c | 8 1 file changed, 8 insertions(+) diff --git a/tlv.c b/tlv.c index 98ef6e1..6e919e6 100644 --- a/tlv.c +++ b/tlv.c @@ -324,6 +324,10 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = ntohs(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = le64_to_cpu(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = le64_to_cpu(psn->stats.txMsgType[i]); + } extra_len = sizeof(struct port_stats_np); break; case TLV_SAVE_IN_NON_VOLATILE_STORAGE: @@ -436,6 +440,10 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = htons(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = cpu_to_le64(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = cpu_to_le64(psn->stats.txMsgType[i]); + } break; } } -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] [PATCH 1/1] Ensure TLV_PORT_STATS_NP statistics uses little endian.
As machine byte order may vary. Ensure TLV_PORT_STATS_NP statistics use defined order. As most of us use little endian hardware and to retain backward compatible with most of us, we decide to use little endian for the statistics. All other TLVs messages remain in network order. Signed-off-by: Erez Geva --- tlv.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/tlv.c b/tlv.c index 98ef6e1..549f2b9 100644 --- a/tlv.c +++ b/tlv.c @@ -128,6 +128,7 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, int extra_len = 0, len; uint8_t *buf; uint16_t u16; + int i; switch (m->id) { case TLV_CLOCK_DESCRIPTION: cd = &extra->cd; @@ -324,6 +325,10 @@ static int mgt_post_recv(struct management_tlv *m, uint16_t data_len, psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = ntohs(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = __le64_to_cpu(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = __le64_to_cpu(psn->stats.txMsgType[i]); + } extra_len = sizeof(struct port_stats_np); break; case TLV_SAVE_IN_NON_VOLATILE_STORAGE: @@ -349,6 +354,7 @@ bad_length: static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) { + int i; struct defaultDS *dds; struct currentDS *cds; struct parentDS *pds; @@ -436,6 +442,10 @@ static void mgt_pre_send(struct management_tlv *m, struct tlv_extra *extra) psn = (struct port_stats_np *)m->data; psn->portIdentity.portNumber = htons(psn->portIdentity.portNumber); + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { + psn->stats.rxMsgType[i] = __cpu_to_le64(psn->stats.rxMsgType[i]); + psn->stats.txMsgType[i] = __cpu_to_le64(psn->stats.txMsgType[i]); + } break; } } -- 2.20.1 ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH 1/1] Ensure TLV_PORT_STATS_NP statistics uses little endian.
On Mon, Mar 15, 2021 at 04:58:09PM +0100, Erez Geva wrote: > diff --git a/tlv.c b/tlv.c > index 98ef6e1..6e919e6 100644 > --- a/tlv.c > +++ b/tlv.c > @@ -324,6 +324,10 @@ static int mgt_post_recv(struct management_tlv *m, > uint16_t data_len, > psn = (struct port_stats_np *)m->data; > psn->portIdentity.portNumber = > ntohs(psn->portIdentity.portNumber); > + for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { > + psn->stats.rxMsgType[i] = > le64_to_cpu(psn->stats.rxMsgType[i]); > + psn->stats.txMsgType[i] = > le64_to_cpu(psn->stats.txMsgType[i]); > + } Thanks for taking this approach. I'm getting build errors. Could you please take a look? /home/richard/git/linuxptp/tlv.c: In function ‘mgt_post_recv’: /home/richard/git/linuxptp/tlv.c:327:8: error: ‘i’ undeclared (first use in this function) for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { ^ /home/richard/git/linuxptp/tlv.c:327:8: note: each undeclared identifier is reported only once for each function it appears in /home/richard/git/linuxptp/tlv.c:328:30: error: implicit declaration of function ‘le64_to_cpu’; did you mean ‘le64toh’? [-Werror=implicit-function-declaration] psn->stats.rxMsgType[i] = le64_to_cpu(psn->stats.rxMsgType[i]); ^~~ le64toh /home/richard/git/linuxptp/tlv.c: In function ‘mgt_pre_send’: /home/richard/git/linuxptp/tlv.c:443:8: error: ‘i’ undeclared (first use in this function) for (i = 0 ; i < MAX_MESSAGE_TYPES; i++) { ^ /home/richard/git/linuxptp/tlv.c:444:30: error: implicit declaration of function ‘cpu_to_le64’; did you mean ‘htole64’? [-Werror=implicit-function-declaration] psn->stats.rxMsgType[i] = cpu_to_le64(psn->stats.rxMsgType[i]); ^~~ htole64 Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] [PATCH 1/1] Ensure TLV_PORT_STATS_NP statistics uses little endian.
On Tue, Mar 23, 2021 at 11:37:39PM +0100, Erez Geva wrote: > As machine byte order may vary. > Ensure TLV_PORT_STATS_NP statistics use defined order. > > As most of us use little endian hardware and > to retain backward compatible with most of us, > we decide to use little endian for the statistics. > All other TLVs messages remain in network order. > > Signed-off-by: Erez Geva Applied. Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel