DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/6] net: changed arp_hdr struct declaration
Date: Fri, 13 Feb 2015 16:16:05 +0100	[thread overview]
Message-ID: <1423840570-6452-2-git-send-email-michalx.k.jastrzebski@intel.com> (raw)
In-Reply-To: <1423840570-6452-1-git-send-email-michalx.k.jastrzebski@intel.com>

Changed MAC address type from uint8_t[6] to struct ether_addr and IP
address type from uint8_t[4] to uint32_t. Also removed union from
arp_hdr struct. Updated test-pmd to match new arp_hdr version.

Signed-off-by: Maciej Gajdzica  <maciejx.t.gajdzica@intel.com>
---
 app/test-pmd/icmpecho.c  |   27 ++++++++++-----------------
 lib/librte_net/rte_arp.h |   13 ++++++-------
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c
index 08ea01d..010c5a9 100644
--- a/app/test-pmd/icmpecho.c
+++ b/app/test-pmd/icmpecho.c
@@ -371,18 +371,14 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
 				continue;
 			}
 			if (verbose_level > 0) {
-				memcpy(&eth_addr,
-				       arp_h->arp_data.arp_ip.arp_sha, 6);
+				ether_addr_copy(&arp_h->arp_data.arp_sha, &eth_addr);
 				ether_addr_dump("        sha=", &eth_addr);
-				memcpy(&ip_addr,
-				       arp_h->arp_data.arp_ip.arp_sip, 4);
+				ip_addr = arp_h->arp_data.arp_sip;
 				ipv4_addr_dump(" sip=", ip_addr);
 				printf("\n");
-				memcpy(&eth_addr,
-				       arp_h->arp_data.arp_ip.arp_tha, 6);
+				ether_addr_copy(&arp_h->arp_data.arp_tha, &eth_addr);
 				ether_addr_dump("        tha=", &eth_addr);
-				memcpy(&ip_addr,
-				       arp_h->arp_data.arp_ip.arp_tip, 4);
+				ip_addr = arp_h->arp_data.arp_tip;
 				ipv4_addr_dump(" tip=", ip_addr);
 				printf("\n");
 			}
@@ -402,17 +398,14 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
 					&eth_h->s_addr);
 
 			arp_h->arp_op = rte_cpu_to_be_16(ARP_OP_REPLY);
-			memcpy(&eth_addr, arp_h->arp_data.arp_ip.arp_tha, 6);
-			memcpy(arp_h->arp_data.arp_ip.arp_tha,
-			       arp_h->arp_data.arp_ip.arp_sha, 6);
-			memcpy(arp_h->arp_data.arp_ip.arp_sha,
-			       &eth_h->s_addr, 6);
+			ether_addr_copy(&arp_h->arp_data.arp_tha, &eth_addr);
+			ether_addr_copy(&arp_h->arp_data.arp_sha, &arp_h->arp_data.arp_tha);
+			ether_addr_copy(&eth_addr, &arp_h->arp_data.arp_sha);
 
 			/* Swap IP addresses in ARP payload */
-			memcpy(&ip_addr, arp_h->arp_data.arp_ip.arp_sip, 4);
-			memcpy(arp_h->arp_data.arp_ip.arp_sip,
-			       arp_h->arp_data.arp_ip.arp_tip, 4);
-			memcpy(arp_h->arp_data.arp_ip.arp_tip, &ip_addr, 4);
+			ip_addr = arp_h->arp_data.arp_sip;
+			arp_h->arp_data.arp_sip = arp_h->arp_data.arp_tip;
+			arp_h->arp_data.arp_tip = ip_addr;
 			pkts_burst[nb_replies++] = pkt;
 			continue;
 		}
diff --git a/lib/librte_net/rte_arp.h b/lib/librte_net/rte_arp.h
index c7b0e51..72108a1 100644
--- a/lib/librte_net/rte_arp.h
+++ b/lib/librte_net/rte_arp.h
@@ -39,6 +39,7 @@
  */
 
 #include <stdint.h>
+#include <rte_ether.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -48,10 +49,10 @@ extern "C" {
  * ARP header IPv4 payload.
  */
 struct arp_ipv4 {
-	uint8_t  arp_sha[6]; /* sender hardware address */
-	uint8_t  arp_sip[4]; /* sender IP address */
-	uint8_t  arp_tha[6]; /* target hardware address */
-	uint8_t  arp_tip[4]; /* target IP address */
+	struct ether_addr  arp_sha;	/* sender hardware address */
+	uint32_t  arp_sip;			/* sender IP address */
+	struct ether_addr  arp_tha;	/* target hardware address */
+	uint32_t  arp_tip;			/* target IP address */
 } __attribute__((__packed__));
 
 /**
@@ -72,9 +73,7 @@ struct arp_hdr {
 #define	ARP_OP_INVREQUEST 8 /* request to identify peer */
 #define	ARP_OP_INVREPLY   9 /* response identifying peer */
 
-	union {
-		struct arp_ipv4 arp_ip;
-	} arp_data;
+	struct arp_ipv4 arp_data;
 } __attribute__((__packed__));
 
 #ifdef __cplusplus
-- 
1.7.9.5

  reply	other threads:[~2015-02-13 15:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 15:16 [dpdk-dev] [PATCH v2 0/6] Link Bonding mode 6 support (ALB) Michal Jastrzebski
2015-02-13 15:16 ` Michal Jastrzebski [this message]
2015-02-13 15:16 ` [dpdk-dev] [PATCH v2 2/6] bond: add link bonding mode 6 implementation Michal Jastrzebski
2015-02-13 15:16 ` [dpdk-dev] [PATCH v2 3/6] bond: add debug info for mode 6 link bonding Michal Jastrzebski
2015-02-13 15:16 ` [dpdk-dev] [PATCH v2 4/6] bond: add example application for link bonding mode 6 Michal Jastrzebski
2015-02-13 15:16 ` [dpdk-dev] [PATCH v2 5/6] bond: modify TLB unit tests Michal Jastrzebski
2015-02-13 15:16 ` [dpdk-dev] [PATCH v2 6/6] bond: add unit tests for link bonding mode 6 Michal Jastrzebski
2015-02-13 16:12 ` [dpdk-dev] [PATCH v2 0/6] Link Bonding mode 6 support (ALB) Declan Doherty
2015-02-18 19:10   ` Thomas Monjalon
2015-02-19  9:18     ` Jastrzebski, MichalX K
2015-02-19  9:39       ` Thomas Monjalon
2015-02-19 10:14         ` Jastrzebski, MichalX K
2015-02-19 10:27           ` Thomas Monjalon
2015-02-19 17:26 ` [dpdk-dev] [PATCH v3 " Michal Jastrzebski
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 1/6] net: changed arp_hdr struct declaration Michal Jastrzebski
2015-02-20 14:30     ` Thomas Monjalon
2015-02-20 14:54       ` Gajdzica, MaciejX T
2015-02-20 15:22         ` Thomas Monjalon
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 2/6] bond: add link bonding mode 6 implementation Michal Jastrzebski
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 3/6] bond: add debug info for mode 6 link bonding Michal Jastrzebski
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 4/6] bond: add example application for link bonding mode 6 Michal Jastrzebski
2015-02-20 14:42     ` Thomas Monjalon
2015-02-20 16:12       ` Jastrzebski, MichalX K
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 5/6] bond: modify TLB unit tests Michal Jastrzebski
2015-02-19 17:26   ` [dpdk-dev] [PATCH v3 6/6] bond: add unit tests for link bonding mode 6 Michal Jastrzebski
2015-02-20 16:09 ` [dpdk-dev] [PATCH v4 0/6] Link Bonding mode 6 support (ALB) Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 1/6] net: changed arp_hdr struct declaration Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 2/6] bond: add link bonding mode 6 implementation Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 3/6] bond: add debug info for mode 6 link bonding Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 4/6] bond: add example application for link bonding mode 6 Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 5/6] bond: modify TLB unit tests Michal Jastrzebski
2015-02-20 16:09   ` [dpdk-dev] [PATCH v4 6/6] bond: add unit tests for link bonding mode 6 Michal Jastrzebski
2015-02-20 17:44   ` [dpdk-dev] [PATCH v4 0/6] Link Bonding mode 6 support (ALB) Declan Doherty
2015-02-20 21:58     ` Thomas Monjalon
2015-03-04  3:53     ` Jiajia, SunX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423840570-6452-2-git-send-email-michalx.k.jastrzebski@intel.com \
    --to=michalx.k.jastrzebski@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).