uint16_t sec_msb;
uint32_t sec_lsb;
uint32_t ns;
-} __attribute__((packed));
+} __rte_packed;
struct clock_id {
uint8_t id[8];
struct port_id {
struct clock_id clock_id;
uint16_t port_number;
-} __attribute__((packed));
+} __rte_packed;
struct ptp_header {
uint8_t msg_type;
uint16_t seq_id;
uint8_t control;
int8_t log_message_interval;
-} __attribute__((packed));
+} __rte_packed;
struct sync_msg {
struct ptp_header hdr;
struct tstamp origin_tstamp;
-} __attribute__((packed));
+} __rte_packed;
struct follow_up_msg {
struct ptp_header hdr;
struct tstamp precise_origin_tstamp;
uint8_t suffix[0];
-} __attribute__((packed));
+} __rte_packed;
struct delay_req_msg {
struct ptp_header hdr;
struct tstamp origin_tstamp;
-} __attribute__((packed));
+} __rte_packed;
struct delay_resp_msg {
struct ptp_header hdr;
struct tstamp rx_tstamp;
struct port_id req_port_id;
uint8_t suffix[0];
-} __attribute__((packed));
+} __rte_packed;
struct ptp_message {
union {
struct delay_req_msg delay_req;
struct follow_up_msg follow_up;
struct delay_resp_msg delay_resp;
- } __attribute__((packed));
+ } __rte_packed;
};
struct ptpv2_data_slave_ordinary {
if (!rte_eth_dev_is_valid_port(port))
return -1;
- rte_eth_dev_info_get(port, &dev_info);
+ retval = rte_eth_dev_info_get(port, &dev_info);
+ if (retval != 0) {
+ printf("Error during getting device (port %u) info: %s\n",
+ port, strerror(-retval));
+
+ return retval;
+ }
+
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
port_conf.txmode.offloads |=
DEV_TX_OFFLOAD_MBUF_FAST_FREE;
return retval;
/* Enable timesync timestamping for the Ethernet device */
- rte_eth_timesync_enable(port);
+ retval = rte_eth_timesync_enable(port);
+ if (retval < 0) {
+ printf("Timesync enable failed: %d\n", retval);
+ return retval;
+ }
/* Enable RX in promiscuous mode for the Ethernet device. */
- rte_eth_promiscuous_enable(port);
+ retval = rte_eth_promiscuous_enable(port);
+ if (retval != 0) {
+ printf("Promiscuous mode enable failed: %s\n",
+ rte_strerror(-retval));
+ return retval;
+ }
return 0;
}
parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
{
struct rte_ether_hdr *eth_hdr;
+ struct rte_ether_addr eth_addr;
struct ptp_header *ptp_hdr;
struct clock_id *client_clkid;
struct ptp_message *ptp_msg;
size_t pkt_size;
int wait_us;
struct rte_mbuf *m = ptp_data->m;
+ int ret;
eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
(((uint64_t)ntohs(origin_tstamp->sec_msb)) << 32);
if (ptp_data->seqID_FOLLOWUP == ptp_data->seqID_SYNC) {
+ ret = rte_eth_macaddr_get(ptp_data->portid, ð_addr);
+ if (ret != 0) {
+ printf("\nCore %u: port %u failed to get MAC address: %s\n",
+ rte_lcore_id(), ptp_data->portid,
+ rte_strerror(-ret));
+ return;
+ }
created_pkt = rte_pktmbuf_alloc(mbuf_pool);
pkt_size = sizeof(struct rte_ether_hdr) +
created_pkt->data_len = pkt_size;
created_pkt->pkt_len = pkt_size;
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
- rte_eth_macaddr_get(ptp_data->portid, ð_hdr->s_addr);
+ rte_ether_addr_copy(ð_addr, ð_hdr->s_addr);
/* Set multicast address 01-1B-19-00-00-00. */
rte_ether_addr_copy(ð_multicast, ð_hdr->d_addr);
ptp_msg->delay_req.hdr.ver = 2;
ptp_msg->delay_req.hdr.control = 1;
ptp_msg->delay_req.hdr.log_message_interval = 127;
+ ptp_msg->delay_req.hdr.message_length =
+ htons(sizeof(struct delay_req_msg));
+ ptp_msg->delay_req.hdr.domain_number = ptp_hdr->domain_number;
/* Set up clock id. */
client_clkid =
* The lcore main. This is the main thread that does the work, reading from an
* input port and writing to an output port.
*/
-static __attribute__((noreturn)) void
+static __rte_noreturn void
lcore_main(void)
{
uint16_t portid;