From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6F0245A6C for ; Thu, 10 Dec 2015 10:30:49 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 10 Dec 2015 01:30:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,407,1444719600"; d="scan'208";a="868699380" Received: from sie-lab-214-036.ir.intel.com (HELO sie-lab-214-174.ir.intel.com) ([10.237.214.36]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2015 01:28:30 -0800 From: Pablo de Lara To: dev@dpdk.org Date: Thu, 10 Dec 2015 09:28:27 +0000 Message-Id: <1449739707-178153-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.0 Subject: [dpdk-dev] [PATCH] app/testpmd: swap mac in IEEE1588 forwarding X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Dec 2015 09:30:49 -0000 IEEE1588 forwarding mode uses same port to receive and transmit packets. In this mode, the MAC address in the packets are not touched, and therefore, packets could be sent with the same destination MAC address as the MAC address of the port that is transmitting, which causes the packet to be dropped in some NICs. In order to avoid this scenario, MAC addresses are swapped before packet is sent out. Signed-off-by: Pablo de Lara --- app/test-pmd/ieee1588fwd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c index c69023a..0d3b37a 100644 --- a/app/test-pmd/ieee1588fwd.c +++ b/app/test-pmd/ieee1588fwd.c @@ -123,6 +123,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs) { struct rte_mbuf *mb; struct ether_hdr *eth_hdr; + struct ether_addr addr; struct ptpv2_msg *ptp_hdr; uint16_t eth_type; uint32_t timesync_index; @@ -205,6 +206,11 @@ ieee1588_packet_fwd(struct fwd_stream *fs) /* Read and check the RX timestamp. */ port_ieee1588_rx_timestamp_check(fs->rx_port, timesync_index); + /* Swap dest and src mac addresses. */ + ether_addr_copy(ð_hdr->d_addr, &addr); + ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr); + ether_addr_copy(&addr, ð_hdr->s_addr); + /* Forward PTP packet with hardware TX timestamp */ mb->ol_flags |= PKT_TX_IEEE1588_TMST; fs->tx_packets += 1; -- 2.5.0