Commit a3e7096b authored by Alessandro Rubini's avatar Alessandro Rubini

userspace/ptpd_netif: remove PACKED

There is no need to use packed structures unless they match hardware
and or stored-structures of legacy processors.  etherpacket here may
look like an issue, but it's naturally aligned by itself. Nobody does it
for a reason.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent a88aa745
......@@ -9,9 +9,6 @@
#define PTPD_SOCK_RAW_ETHERNET 1
#define PTPD_SOCK_UDP 2
// GCC-specific
#define PACKED __attribute__((packed))
// WhiteRabbit socket - it's void pointer as the real socket structure is private and probably platform-specific.
typedef void *wr_socket_t;
......@@ -52,7 +49,7 @@ struct wr_socket {
};
#endif
PACKED struct _wr_timestamp {
struct wr_tstamp {
// Seconds
int64_t sec;
......@@ -73,8 +70,6 @@ PACKED struct _wr_timestamp {
//int cntr_ahead;
};
typedef struct _wr_timestamp wr_timestamp_t;
/* OK. These functions we'll develop along with network card driver. You can write your own UDP-based stubs for testing purposes. */
// Initialization of network interface:
......@@ -94,13 +89,13 @@ wr_socket_t *ptpd_netif_create_socket(int sock_type, int flags,
// for recovering the precise transmit timestamp. If user doesn't need it, tag parameter can be left NULL.
int ptpd_netif_sendto(wr_socket_t * sock, wr_sockaddr_t * to, void *data,
size_t data_length, wr_timestamp_t * tx_ts);
size_t data_length, struct wr_tstamp *tx_ts);
// Receives an UDP/RAW packet. Data is written to (data) and length is returned. Maximum buffer length can be specified
// by data_length parameter. Sender information is stored in structure specified in 'from'. All RXed packets are timestamped and the timestamp
// is stored in rx_timestamp (unless it's NULL).
int ptpd_netif_recvfrom(wr_socket_t * sock, wr_sockaddr_t * from, void *data,
size_t data_length, wr_timestamp_t * rx_timestamp);
size_t data_length, struct wr_tstamp *rx_timestamp);
// Closes the socket.
int ptpd_netif_close_socket(wr_socket_t * sock);
......@@ -119,7 +114,7 @@ int ptpd_netif_poll(wr_socket_t *);
/* Timebase adjustment functions - the servo should not call the HAL directly */
int ptpd_netif_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec);
int ptpd_netif_get_dmtd_phase(wr_socket_t * sock, int32_t * phase);
void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
void ptpd_netif_linearize_rx_timestamp(struct wr_tstamp *ts, int32_t dmtd_phase,
int cntr_ahead, int transition_point,
int clock_period);
......
......@@ -24,6 +24,7 @@
#include <libwr/ptpd_netif.h>
#include <libwr/hal_client.h>
#include <net/ethernet.h>
#ifdef NETIF_VERBOSE
#define netif_dbg(...) printf(__VA_ARGS__)
......@@ -40,9 +41,9 @@ struct scm_timestamping {
struct timespec hwtimeraw;
};
PACKED struct etherpacket {
struct etherpacket {
struct ethhdr ether;
char data[ETHER_MTU];
char data[ETH_DATA_LEN];
};
static uint64_t get_tics()
......@@ -110,7 +111,7 @@ static void update_dmtd(wr_socket_t * sock)
}
}
void ptpd_netif_linearize_rx_timestamp(wr_timestamp_t * ts, int32_t dmtd_phase,
void ptpd_netif_linearize_rx_timestamp(struct wr_tstamp *ts, int32_t dmtd_phase,
int cntr_ahead, int transition_point,
int clock_period)
{
......@@ -291,10 +292,10 @@ int ptpd_netif_close_socket(wr_socket_t * sock)
}
static void poll_tx_timestamp(wr_socket_t * sock,
wr_timestamp_t * tx_timestamp);
struct wr_tstamp *tx_timestamp);
int ptpd_netif_sendto(wr_socket_t * sock, wr_sockaddr_t * to, void *data,
size_t data_length, wr_timestamp_t * tx_ts)
size_t data_length, struct wr_tstamp *tx_ts)
{
struct etherpacket pkt;
struct wr_socket *s = (struct wr_socket *)sock;
......@@ -347,7 +348,7 @@ static void hdump(uint8_t * buf, int size)
#endif
/* Waits for the transmission timestamp and stores it in tx_timestamp (if not null). */
static void poll_tx_timestamp(wr_socket_t * sock, wr_timestamp_t * tx_timestamp)
static void poll_tx_timestamp(wr_socket_t * sock, struct wr_tstamp *tx_timestamp)
{
char data[16384];
......@@ -411,7 +412,7 @@ static void poll_tx_timestamp(wr_socket_t * sock, wr_timestamp_t * tx_timestamp)
}
int ptpd_netif_recvfrom(wr_socket_t * sock, wr_sockaddr_t * from, void *data,
size_t data_length, wr_timestamp_t * rx_timestamp)
size_t data_length, struct wr_tstamp *rx_timestamp)
{
struct wr_socket *s = (struct wr_socket *)sock;
struct etherpacket pkt;
......
......@@ -242,7 +242,7 @@ static void print_cal_stats()
void calc_trans(int ep, int argc, char *argv[])
{
wr_timestamp_t ts_tx, ts_rx;
struct wr_tstamp ts_tx, ts_rx;
wr_socket_t *sock;
FILE *f_log = NULL;
wr_sockaddr_t sock_addr, from;
......@@ -354,7 +354,7 @@ void analyze_phase_log(int ep, int argc, char *argv[])
while(!feof(f_log))
{
wr_timestamp_t ts_tx, ts_rx;
struct wr_tstamp ts_tx, ts_rx;
fscanf(f_log, "%d %d %d %d %d\n", &bitslide, &ts_tx.nsec, &ts_rx.raw_nsec, &ts_rx.raw_phase, &ts_rx.raw_ahead);
ts_rx.nsec = ts_rx.raw_nsec;
......@@ -374,7 +374,7 @@ void analyze_phase_log(int ep, int argc, char *argv[])
void pps_adjustment_test(int ep, int argc, char *argv[])
{
wr_timestamp_t ts_tx, ts_rx;
struct wr_tstamp ts_tx, ts_rx;
wr_socket_t *sock;
wr_sockaddr_t sock_addr, from;
int adjust_count = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment