Skip to content

Commit

Permalink
check: Refactor and create base for test cases
Browse files Browse the repository at this point in the history
- Make tx_timestamp_timeout an argument
- Import latest WMO net_tstamp.h
- Set up an example test case

Signed-off-by: Casper Andersson <[email protected]>
  • Loading branch information
cappe987 committed Oct 6, 2024
1 parent c82753d commit ab8f9f1
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 75 deletions.
14 changes: 14 additions & 0 deletions include/net_tstamp_cpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ struct so_timestamping {
* @tx_type: one of HWTSTAMP_TX_*
* @rx_filter: one of HWTSTAMP_FILTER_*
* @clk_type one of HWTSTAMP_CLOCK_TYPE_*
* @domain domain number
* @header_offset how much further into the frame it should search for
* the PTP header. 0 = start at byte 12. Useful when
* combined with HSR tags.
* @delay_mechanism one of HWTSTAMP_DELAY_MECHANISM_*
*
* %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
* ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
Expand All @@ -80,6 +85,9 @@ struct hwtstamp_config {
int tx_type;
int rx_filter;
int clk_type;
int domain;
int header_offset;
int delay_mechanism;
};

/* possible values for hwtstamp_config->flags */
Expand Down Expand Up @@ -190,6 +198,12 @@ enum hwtstamp_clk_types {
HWTSTAMP_CLOCK_TYPE_BOUNDARY_CLOCK,
};

enum hwtstamp_delay_mechanism {
HWTSTAMP_DELAY_MECHANISM_OFF,
HWTSTAMP_DELAY_MECHANISM_E2E,
HWTSTAMP_DELAY_MECHANISM_P2P,
};

/* SCM_TIMESTAMPING_PKTINFO control message */
struct scm_ts_pktinfo {
__u32 if_index;
Expand Down
11 changes: 11 additions & 0 deletions include/pkt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: 2024 Casper Andersson <[email protected]>

#include "net_tstamp_cpy.h"
#include "timestamping.h"
#include "tstest.h"

#define SEQUENCE_MAX 100

struct pkt_cfg {
Expand All @@ -17,11 +21,18 @@ struct pkt_cfg {
int domain;
int tstype;
int count;
int vlan;
int prio;
int seq;
unsigned char mac[ETH_ALEN];
char *interface;
int sequence_types[SEQUENCE_MAX];
int sequence_length;
enum delay_mechanism dm;
enum hwtstamp_clk_types clk_type;
};

int msg_get_type(union Message *msg);
union Message build_msg(struct pkt_cfg *cfg, int type);
int send_msg(struct pkt_cfg *cfg, int sock, union Message *msg, int64_t *ns);
int build_and_send(struct pkt_cfg *cfg, int sock, int type, struct hw_timestamp *hwts, int64_t *ns);
12 changes: 8 additions & 4 deletions include/timestamping.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <inttypes.h>
#include <sys/un.h>

#define DEFAULT_TX_TIMEOUT 1000

/* A lot taken from Linuxptp project */

#define NS_PER_SEC 1000000000
Expand Down Expand Up @@ -117,11 +119,13 @@ static unsigned char ptp_dst_mac[] = { 0x01, 0x1B, 0x19, 0x00, 0x00, 0x00 };
static unsigned char p2p_dst_mac[] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E };

int sk_receive(int fd, void *buf, int buflen, struct address *addr, struct hw_timestamp *hwts,
int flags);
int flags, int sk_tx_timeout);
int raw_send(int fd, enum transport_event event, void *buf, int len, struct hw_timestamp *hwts);
int sk_timestamping_destroy(int fd, const char *device);
int sk_timestamping_init(int fd, const char *device, enum timestamp_type type,
enum transport_type transport, int vclock);
int sk_timestamping_destroy(int fd, const char *device, int tstype);
int sk_timestamping_init(int fd, const char *device, int clk_type, enum timestamp_type type,
enum transport_type transport, int vclock, int domain,
enum delay_mechanism dm, int header_offset);

//int socket_init_raw(char *interface);
int open_socket(const char *name, int event, unsigned char *ptp_dst_mac, unsigned char *p2p_dst_mac,
int socket_priority, int ena_filters);
Expand Down
Loading

0 comments on commit ab8f9f1

Please sign in to comment.