X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fptpclient%2Fptpclient.c;h=d94eca0353d76cc1b0b3ff191d93e0861260b6c5;hb=c4045f34557a5ce3de2b14e997fe41b122595e29;hp=878d1a0b999cc7b1c4a5cacb8633d7dc8dfa1163;hpb=e1d10a42f6e0e44b07ea7936f6704b93a8d2a1ef;p=dpdk.git diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index 878d1a0b99..d94eca0353 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -217,8 +217,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) /* Allocate and set up 1 RX queue per Ethernet port. */ for (q = 0; q < rx_rings; q++) { + struct rte_eth_rxconf *rxconf; + + rxconf = &dev_info.default_rxconf; + rxconf->offloads = port_conf.rxmode.offloads; + retval = rte_eth_rx_queue_setup(port, q, nb_rxd, - rte_eth_dev_socket_id(port), NULL, mbuf_pool); + rte_eth_dev_socket_id(port), rxconf, mbuf_pool); if (retval < 0) return retval; @@ -426,10 +431,10 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data) created_pkt->data_len = pkt_size; created_pkt->pkt_len = pkt_size; eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *); - rte_ether_addr_copy(ð_addr, ð_hdr->s_addr); + rte_ether_addr_copy(ð_addr, ð_hdr->src_addr); /* Set multicast address 01-1B-19-00-00-00. */ - rte_ether_addr_copy(ð_multicast, ð_hdr->d_addr); + rte_ether_addr_copy(ð_multicast, ð_hdr->dst_addr); eth_hdr->ether_type = htons(PTP_PROTOCOL); ptp_msg = (struct ptp_message *) @@ -449,14 +454,14 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data) client_clkid = &ptp_msg->delay_req.hdr.source_port_id.clock_id; - client_clkid->id[0] = eth_hdr->s_addr.addr_bytes[0]; - client_clkid->id[1] = eth_hdr->s_addr.addr_bytes[1]; - client_clkid->id[2] = eth_hdr->s_addr.addr_bytes[2]; + client_clkid->id[0] = eth_hdr->src_addr.addr_bytes[0]; + client_clkid->id[1] = eth_hdr->src_addr.addr_bytes[1]; + client_clkid->id[2] = eth_hdr->src_addr.addr_bytes[2]; client_clkid->id[3] = 0xFF; client_clkid->id[4] = 0xFE; - client_clkid->id[5] = eth_hdr->s_addr.addr_bytes[3]; - client_clkid->id[6] = eth_hdr->s_addr.addr_bytes[4]; - client_clkid->id[7] = eth_hdr->s_addr.addr_bytes[5]; + client_clkid->id[5] = eth_hdr->src_addr.addr_bytes[3]; + client_clkid->id[6] = eth_hdr->src_addr.addr_bytes[4]; + client_clkid->id[7] = eth_hdr->src_addr.addr_bytes[5]; rte_memcpy(&ptp_data->client_clock_id, client_clkid, @@ -563,6 +568,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data) /* This function processes PTP packets, implementing slave PTP IEEE1588 L2 * functionality. */ + +/* Parse ptp frames. 8< */ static void parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) { struct ptp_header *ptp_hdr; @@ -594,6 +601,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) { } } } +/* >8 End of function processes PTP packets. */ /* * The lcore main. This is the main thread that does the work, reading from an @@ -612,7 +620,7 @@ lcore_main(void) /* Run until the application is quit or killed. */ while (1) { - /* Read packet from RX queues. */ + /* Read packet from RX queues. 8< */ for (portid = 0; portid < ptp_enabled_port_nb; portid++) { portid = ptp_enabled_ports[portid]; @@ -621,11 +629,14 @@ lcore_main(void) if (likely(nb_rx == 0)) continue; + /* Packet is parsed to determine which type. 8< */ if (m->ol_flags & PKT_RX_IEEE1588_PTP) parse_ptp_frames(portid, m); + /* >8 End of packet is parsed to determine which type. */ rte_pktmbuf_free(m); } + /* >8 End of read packets from RX queues. */ } } @@ -732,32 +743,36 @@ main(int argc, char *argv[]) uint16_t portid; - /* Initialize the Environment Abstraction Layer (EAL). */ + /* Initialize the Environment Abstraction Layer (EAL). 8< */ int ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Error with EAL initialization\n"); + /* >8 End of initialization of EAL. */ memset(&ptp_data, '\0', sizeof(struct ptpv2_data_slave_ordinary)); + /* Parse specific arguments. 8< */ argc -= ret; argv += ret; ret = ptp_parse_args(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); + /* >8 End of parsing specific arguments. */ /* Check that there is an even number of ports to send/receive on. */ nb_ports = rte_eth_dev_count_avail(); - /* Creates a new mempool in memory to hold the mbufs. */ + /* Creates a new mempool in memory to hold the mbufs. 8< */ mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL", NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); + /* >8 End of a new mempool in memory to hold the mbufs. */ if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); - /* Initialize all ports. */ + /* Initialize all ports. 8< */ RTE_ETH_FOREACH_DEV(portid) { if ((ptp_enabled_port_mask & (1 << portid)) != 0) { if (port_init(portid, mbuf_pool) == 0) { @@ -771,6 +786,7 @@ main(int argc, char *argv[]) } else printf("Skipping disabled port %u\n", portid); } + /* >8 End of initialization of all ports. */ if (ptp_enabled_port_nb == 0) { rte_exit(EXIT_FAILURE, @@ -784,5 +800,8 @@ main(int argc, char *argv[]) /* Call lcore_main on the main core only. */ lcore_main(); + /* clean up the EAL */ + rte_eal_cleanup(); + return 0; }