Skip to content

Commit 7d22d68

Browse files
author
Levi Pearson
committed
Finished merge, made whitespace consistent
1 parent d29b57d commit 7d22d68

22 files changed

+2704
-774
lines changed

daemons/gptp/README_AVNU_AP.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
## Introduction
2+
This readme covers only the additional features added to the gPTP daemon
3+
to support the AVnu Automotive Profile (AP).
4+
5+
## Automotive Profile Features Implemented
6+
- In general all features of the AP support for a Slave device have been
7+
implemented with the following exceptions.
8+
- Windows OS platform code has not been implemented.
9+
- Detailed list of the AP implementation includes
10+
- Configuration
11+
- Static gPTP values (AutoCDS 6.2.1)
12+
- Persistent gPTP values (AutoCDS 6.2.2)
13+
- Management Updated Values (AutoCDS 6.2.3)
14+
- Signalling Message Configuration (AutoCDS 6.2.4)
15+
- Followup TLV (AutoCDS 6.2.5)
16+
- Required Values for gPTP (AutoCDS 6.2.6)
17+
- Operation
18+
- Disable BMCA (AutoCDS 6.3)
19+
- No verification of sourcePortIdentity (AutoCDS 6.3)
20+
- Sync Holdover (AutoCDS 6.3)
21+
- Sync Recovery (AutoCDS 6.3)
22+
- Implement Signalling Message (802.1AS 2011 10.5.4)
23+
- Implement Test Mode (AutoCDS 5.3)
24+
- Exception Handling
25+
- Link State Change (AutoCDS 9.2.1)
26+
- Loss of Sync Messages (AutoCDS 9.3.1)
27+
- Non-Continuous Sync Values (AutoCDS 9.3.2)
28+
- Pdelay Response Timeout (AutoCDS 9.3.3) (Not implemented)
29+
- neighborPropDelay value (AutoCDS 9.3.4)
30+
- Diagnostic counters (AutoCDS 13)
31+
- Abstracted with only simple dump to log upon SIGUSR2 signal.
32+
33+
## Non-Automotive Profile Changes
34+
- Added fuller feature logging within gPTP
35+
- Updated the various logging macros and direct usage of printfs to use the new
36+
logging
37+
- IEEE1588Port class initialization changed to reduced the 14+ constructor
38+
parameters to a single init parameter.
39+
- Link up and Link down detection added.
40+
- Abstracted the state save functionality to allow for easier integration to
41+
other platforms.
42+
43+
## New Command Line Options
44+
- E enable test mode (as defined in AVnu automotive profile)
45+
- V enable AVnu Automotive Profile
46+
- GM set grandmaster for Automotive Profile
47+
- INITSYNC <value> initial sync interval (Log base 2. 0 = 1 sec)
48+
- OPERSYNC <value> operational sync interval (Log base 2. 0 = 1 sec)
49+
- INITPDELAY <value> initial pdelay interval (Log base 2. 0 = 1 sec)
50+
- OPERPDELAY <value> operational pdelay interval (Log base 2. 0 = 1 sec)
51+
52+
## Build Related
53+
- There are no changes to the standard build for gPTP
54+
55+
## Execution Related
56+
- Other than the new command line options there are no changes to starting gPTP
57+
- Example
58+
- ./run_gptp.sh eth1 -M statefile -V
59+
- Start with AP and a specific file name for saving state information.
60+
61+
## Run Time Related
62+
- Signals
63+
- SIGHUP: writes the current gPTP state information to file.
64+
- SIGUSR2: Dumps the diagnostic counters to the log
65+
66+
## Known Issues
67+
- When running as slave (none -GM) there may be a SYNC rx timeout exception reported when signalling to a different SYNC rate.
68+
- Link down or link up may be incorrectly detected at times.
69+
70+
## Windows Functionality That is Missing
71+
- The initial implementation of the Automotive Profile for gPTP was done for Linux only.
72+
- To locate the functionality that must be implemented for windows one approach is to look at the pull request
73+
at https://github.com/AVnu/Open-AVB/pull/355 and review all the differences in the Linux folder.
74+
- Brief summary to give a sense of scope of updates needed for Windows
75+
- MakeFile
76+
- Updates for new files
77+
- daemon_cl.cpp
78+
- New command line options
79+
- Port init via struct rather than separate parameters for the constructor
80+
- Changed state save and restore (persistence)
81+
- Automotive profile configuration setup
82+
- Updates to signal handling
83+
- Logging changes
84+
- Other updates as well
85+
- linux_hal_common.cpp
86+
- Link Up and Down functionality
87+
- Logging changes
88+
- linux_hal_common.hpp
89+
- Function prototypes updated
90+
- linux_hal_generic.cpp
91+
- Logging changes
92+
- linux_hal_intelce.cpp
93+
- Logging changes
94+
- linux_hal_persist_file.cpp
95+
- New functionality
96+
- linux_hal_persist_file.hpp
97+
- New functionality
98+

daemons/gptp/common/ap_message.cpp

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*************************************************************************************************************
2+
Copyright (c) 2012-2016, Harman International Industries, Incorporated
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS LISTED "AS IS" AND
15+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS LISTED BE LIABLE FOR
18+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*************************************************************************************************************/
25+
26+
#include <ieee1588.hpp>
27+
#include <avbts_clock.hpp>
28+
#include <avbap_message.hpp>
29+
#include <avbts_port.hpp>
30+
#include <avbts_ostimer.hpp>
31+
#include <gptp_log.hpp>
32+
33+
#include <stdio.h>
34+
#include <string.h>
35+
#include <math.h>
36+
37+
38+
#define ntohll(x) __bswap_64 (x)
39+
#define htonll(x) __bswap_64 (x)
40+
41+
42+
// Octet based data 2 buffer macros
43+
#define OCT_D2BMEMCP(d, s) memcpy(d, s, sizeof(s)); d += sizeof(s);
44+
#define OCT_D2BBUFCP(d, s, len) memcpy(d, s, len); d += len;
45+
#define OCT_D2BHTONB(d, s) *(U8 *)(d) = s; d += sizeof(s);
46+
#define OCT_D2BHTONS(d, s) *(U16 *)(d) = PLAT_htons(s); d += sizeof(s);
47+
#define OCT_D2BHTONL(d, s) *(U32 *)(d) = PLAT_htonl(s); d += sizeof(s);
48+
49+
// Bit based data 2 buffer macros
50+
#define BIT_D2BHTONB(d, s, shf) *(uint8_t *)(d) |= s << shf;
51+
#define BIT_D2BHTONS(d, s, shf) *(uint16_t *)(d) |= PLAT_htons((uint16_t)(s << shf));
52+
#define BIT_D2BHTONL(d, s, shf) *(uint32_t *)(d) |= PLAT_htonl((uint32_t)(s << shf));
53+
54+
55+
APMessageTestStatus::APMessageTestStatus()
56+
{
57+
}
58+
59+
APMessageTestStatus::~APMessageTestStatus()
60+
{
61+
}
62+
63+
APMessageTestStatus::APMessageTestStatus(IEEE1588Port * port)
64+
{
65+
}
66+
67+
void APMessageTestStatus::sendPort(IEEE1588Port * port)
68+
{
69+
static uint16_t sequenceId = 0;
70+
71+
uint8_t buf_t[256];
72+
uint8_t *buf_ptr = buf_t + port->getPayloadOffset();
73+
uint16_t tmp16;
74+
uint32_t tmp32;
75+
uint64_t tmp64;
76+
77+
memset(buf_t, 0, 256);
78+
79+
// Create packet in buf
80+
messageLength = AP_TEST_STATUS_LENGTH;
81+
82+
BIT_D2BHTONB(buf_ptr + AP_TEST_STATUS_AVTP_SUBTYPE(AP_TEST_STATUS_OFFSET), 0xfb, 0);
83+
BIT_D2BHTONB(buf_ptr + AP_TEST_STATUS_AVTP_VERSION_CONTROL(AP_TEST_STATUS_OFFSET), 0x1, 0);
84+
BIT_D2BHTONS(buf_ptr + AP_TEST_STATUS_AVTP_STATUS_LENGTH(AP_TEST_STATUS_OFFSET), 148, 0);
85+
86+
port->getLocalAddr()->toOctetArray(buf_ptr + AP_TEST_STATUS_TARGET_ENTITY_ID(AP_TEST_STATUS_OFFSET));
87+
88+
tmp16 = PLAT_htons(sequenceId++);
89+
memcpy(buf_ptr + AP_TEST_STATUS_SEQUENCE_ID(AP_TEST_STATUS_OFFSET), &tmp16, sizeof(tmp16));
90+
91+
BIT_D2BHTONS(buf_ptr + AP_TEST_STATUS_COMMAND_TYPE(AP_TEST_STATUS_OFFSET), 1, 15);
92+
BIT_D2BHTONS(buf_ptr + AP_TEST_STATUS_COMMAND_TYPE(AP_TEST_STATUS_OFFSET), 0x29, 0);
93+
94+
tmp16 = PLAT_htons(0x09);
95+
memcpy(buf_ptr + AP_TEST_STATUS_DESCRIPTOR_TYPE(AP_TEST_STATUS_OFFSET), &tmp16, sizeof(tmp16));
96+
tmp16 = PLAT_htons(0x00);
97+
memcpy(buf_ptr + AP_TEST_STATUS_DESCRIPTOR_INDEX(AP_TEST_STATUS_OFFSET), &tmp16, sizeof(tmp16));
98+
99+
tmp32 = PLAT_htonl(0x07000023);
100+
memcpy(buf_ptr + AP_TEST_STATUS_COUNTERS_VALID(AP_TEST_STATUS_OFFSET), &tmp32, sizeof(tmp32));
101+
102+
tmp32 = PLAT_htonl(port->getLinkUpCount());
103+
memcpy(buf_ptr + AP_TEST_STATUS_COUNTER_LINKUP(AP_TEST_STATUS_OFFSET), &tmp32, sizeof(tmp32));
104+
105+
tmp32 = PLAT_htonl(port->getLinkDownCount());
106+
memcpy(buf_ptr + AP_TEST_STATUS_COUNTER_LINKDOWN(AP_TEST_STATUS_OFFSET), &tmp32, sizeof(tmp32));
107+
108+
Timestamp system_time;
109+
Timestamp device_time;
110+
uint32_t local_clock, nominal_clock_rate;
111+
port->getDeviceTime(system_time, device_time, local_clock, nominal_clock_rate);
112+
tmp64 = htonll(TIMESTAMP_TO_NS(system_time));
113+
memcpy(buf_ptr + AP_TEST_STATUS_MESSAGE_TIMESTAMP(AP_TEST_STATUS_OFFSET), &tmp64, sizeof(tmp64));
114+
115+
BIT_D2BHTONB(buf_ptr + AP_TEST_STATUS_STATION_STATE(AP_TEST_STATUS_OFFSET), (uint8_t)port->getStationState(), 0);
116+
117+
if (port->getStationState() == STATION_STATE_ETHERNET_READY) {
118+
GPTP_LOG_INFO("AVnu AP Status : STATION_STATE_ETHERNET_READY");
119+
}
120+
else if (port->getStationState() == STATION_STATE_AVB_SYNC) {
121+
GPTP_LOG_INFO("AVnu AP Status : STATION_STATE_AVB_SYNC");
122+
}
123+
else if (port->getStationState() == STATION_STATE_AVB_MEDIA_READY) {
124+
GPTP_LOG_INFO("AVnu AP Status : STATION_STATE_AVB_MEDIA_READY");
125+
}
126+
127+
port->sendGeneralPort(AVTP_ETHERTYPE, buf_t, messageLength, MCAST_TEST_STATUS, NULL);
128+
129+
return;
130+
}
131+

daemons/gptp/common/avbap_message.hpp

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*************************************************************************************************************
2+
Copyright (c) 2012-2016, Harman International Industries, Incorporated
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS LISTED "AS IS" AND
15+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS LISTED BE LIABLE FOR
18+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*************************************************************************************************************/
25+
26+
#ifndef AVBAP_MESSAGE_HPP
27+
#define AVBAP_MESSAGE_HPP
28+
29+
#include <stdint.h>
30+
#include <avbts_osnet.hpp>
31+
#include <ieee1588.hpp>
32+
33+
#include <list>
34+
#include <algorithm>
35+
#include <avbts_message.hpp>
36+
37+
/** @file **/
38+
39+
#define AP_TEST_STATUS_OFFSET 0 /*!< AP Test Status offset */
40+
#define AP_TEST_STATUS_LENGTH 160 /*!< AP Test Status length in byte */
41+
#define AP_TEST_STATUS_AVTP_SUBTYPE(x) x /*!< AVTP Subtype */
42+
#define AP_TEST_STATUS_AVTP_VERSION_CONTROL(x) x + 1 /*!< Version and control fields */
43+
#define AP_TEST_STATUS_AVTP_STATUS_LENGTH(x) x + 2 /*!< Status and content length */
44+
#define AP_TEST_STATUS_TARGET_ENTITY_ID(x) x + 4 /*!< Target entity ID */
45+
#define AP_TEST_STATUS_CONTROLLER_ENTITY_ID(x) x + 12 /*!< Controller entity ID */
46+
#define AP_TEST_STATUS_SEQUENCE_ID(x) x + 20 /*!< Sequence ID */
47+
#define AP_TEST_STATUS_COMMAND_TYPE(x) x + 22 /*!< Command type */
48+
#define AP_TEST_STATUS_DESCRIPTOR_TYPE(x) x + 24 /*!< Descriptor Type */
49+
#define AP_TEST_STATUS_DESCRIPTOR_INDEX(x) x + 26 /*!< Descriptor Index */
50+
#define AP_TEST_STATUS_COUNTERS_VALID(x) x + 28 /*!< Counters valid */
51+
#define AP_TEST_STATUS_COUNTER_LINKUP(x) x + 32 /*!< Counter Link Up */
52+
#define AP_TEST_STATUS_COUNTER_LINKDOWN(x) x + 36 /*!< Counter Link Down */
53+
#define AP_TEST_STATUS_COUNTER_FRAMES_TX(x) x + 40 /*!< Counter Frames TX */
54+
#define AP_TEST_STATUS_COUNTER_FRAMES_RX(x) x + 44 /*!< Counter Frames RX */
55+
#define AP_TEST_STATUS_COUNTER_FRAMES_RX_CRC_ERROR(x) x + 48 /*!< Counter Frames RX CRC Error */
56+
#define AP_TEST_STATUS_COUNTER_GM_CHANGED(x) x + 52 /*!< Counter GM Changed */
57+
#define AP_TEST_STATUS_COUNTER_RESERVED(x) x + 56 /*!< Reserved counters */
58+
#define AP_TEST_STATUS_MESSAGE_TIMESTAMP(x) x + 128 /*!< Message timestamp */
59+
#define AP_TEST_STATUS_STATION_STATE(x) x + 136 /*!< Station state */
60+
#define AP_TEST_STATUS_STATION_STATE_SPECIFIC_DATA(x) x + 137 /*!< Station state specific data */
61+
#define AP_TEST_STATUS_COUNTER_27(x) x + 140 /*!< Counter 27 */
62+
#define AP_TEST_STATUS_COUNTER_28(x) x + 144 /*!< Counter 28 */
63+
#define AP_TEST_STATUS_COUNTER_29(x) x + 148 /*!< Counter 29 */
64+
#define AP_TEST_STATUS_COUNTER_30(x) x + 152 /*!< Counter 30 */
65+
#define AP_TEST_STATUS_COUNTER_31(x) x + 156 /*!< Counter 31 */
66+
67+
68+
/**
69+
* Automotive Profile Test Status Station State
70+
*/
71+
typedef enum {
72+
STATION_STATE_RESERVED,
73+
STATION_STATE_ETHERNET_READY,
74+
STATION_STATE_AVB_SYNC,
75+
STATION_STATE_AVB_MEDIA_READY,
76+
} StationState_t;
77+
78+
79+
/**
80+
* Provides a class for building the ANvu Automotive
81+
* Profile Test Status message
82+
*/
83+
class APMessageTestStatus {
84+
private:
85+
uint16_t messageLength; /*!< message length */
86+
87+
APMessageTestStatus();
88+
public:
89+
/**
90+
* @brief Default constructor. Creates APMessageTestStatus
91+
* @param port IEEE1588Port
92+
*/
93+
APMessageTestStatus(IEEE1588Port * port);
94+
95+
/**
96+
* Destroys APMessageTestStatus interface
97+
*/
98+
~APMessageTestStatus();
99+
100+
/**
101+
* @brief Assembles APMessageTestStatus message on the
102+
* IEEE1588Port payload
103+
* @param port IEEE1588Port where the message will be assembled
104+
* @return void
105+
*/
106+
void sendPort(IEEE1588Port * port);
107+
};
108+
109+
110+
#endif

0 commit comments

Comments
 (0)