From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH 1/2] examples/l2fwd: Add new option to enable/disable MAC addresses tweaking
Date: Tue, 26 Jul 2016 17:56:26 +0200 [thread overview]
Message-ID: <1469548587-3202-2-git-send-email-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <1469548587-3202-1-git-send-email-maxime.coquelin@redhat.com>
l2fwd could be useful for testing virtual devices without the need
of physical ones.
To achieve this, this patch adds a new option to enable/disable the
MAC addresses tweaking done at forwarding time: --[no-]mac-tweaking
By default, MAC address tweaking remains enabled, to keep consistency
with previous usage.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
examples/l2fwd/main.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 8897921..2693be1 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -74,6 +74,9 @@
static volatile bool force_quit;
+/* MAC tweaking enabled by default */
+static int mac_tweaking = 1;
+
#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
#define NB_MBUF 8192
@@ -186,23 +189,32 @@ print_stats(void)
}
static void
-l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid)
+l2fwd_mac_tweaking(struct rte_mbuf *m, unsigned dest_portid)
{
struct ether_hdr *eth;
void *tmp;
- unsigned dst_port;
- int sent;
- struct rte_eth_dev_tx_buffer *buffer;
- dst_port = l2fwd_dst_ports[portid];
eth = rte_pktmbuf_mtod(m, struct ether_hdr *);
/* 02:00:00:00:00:xx */
tmp = ð->d_addr.addr_bytes[0];
- *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dst_port << 40);
+ *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40);
/* src addr */
- ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], ð->s_addr);
+ ether_addr_copy(&l2fwd_ports_eth_addr[dest_portid], ð->s_addr);
+}
+
+static void
+l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid)
+{
+ unsigned dst_port;
+ int sent;
+ struct rte_eth_dev_tx_buffer *buffer;
+
+ dst_port = l2fwd_dst_ports[portid];
+
+ if (mac_tweaking)
+ l2fwd_mac_tweaking(m, dst_port);
buffer = tx_buffer[dst_port];
sent = rte_eth_tx_buffer(dst_port, 0, buffer, m);
@@ -322,7 +334,11 @@ l2fwd_usage(const char *prgname)
printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n"
" -p PORTMASK: hexadecimal bitmask of ports to configure\n"
" -q NQ: number of queue (=ports) per lcore (default is 1)\n"
- " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n",
+ " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n"
+ " --[no-]mac-tweaking: Enable or disable MAC addresses tweaking (enabled by default)\n"
+ " When enabled:\n"
+ " - The source MAC address is replaced by the TX port MAC address\n"
+ " - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n",
prgname);
}
@@ -386,6 +402,8 @@ l2fwd_parse_args(int argc, char **argv)
int option_index;
char *prgname = argv[0];
static struct option lgopts[] = {
+ { "mac-tweaking", no_argument, &mac_tweaking, 1},
+ { "no-mac-tweaking", no_argument, &mac_tweaking, 0},
{NULL, 0, 0, 0}
};
@@ -428,8 +446,7 @@ l2fwd_parse_args(int argc, char **argv)
/* long options */
case 0:
- l2fwd_usage(prgname);
- return -1;
+ break;
default:
l2fwd_usage(prgname);
@@ -542,6 +559,8 @@ main(int argc, char **argv)
if (ret < 0)
rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n");
+ printf("MAC tweaking %s\n", mac_tweaking ? "enabled" : "disabled");
+
/* convert to number of cycles */
timer_period *= rte_get_timer_hz();
--
2.7.4
next prev parent reply other threads:[~2016-07-26 15:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-26 15:56 [dpdk-dev] [PATCH 0/2] examples/l2fwd: Add " Maxime Coquelin
2016-07-26 15:56 ` Maxime Coquelin [this message]
2016-08-30 15:42 ` [dpdk-dev] [PATCH 1/2] examples/l2fwd: Add new " Mcnamara, John
2016-07-26 15:56 ` [dpdk-dev] [PATCH 2/2] doc: l2fwd: document new --[no-]mac-tweaking option Maxime Coquelin
2016-08-30 15:42 ` [dpdk-dev] [PATCH 0/2] examples/l2fwd: Add option to enable/disable MAC addresses tweaking Mcnamara, John
2016-09-23 13:54 ` Maxime Coquelin
2016-09-21 21:53 ` De Lara Guarch, Pablo
2016-09-23 13:52 ` Maxime Coquelin
2016-09-23 17:11 ` De Lara Guarch, Pablo
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=1469548587-3202-2-git-send-email-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=pablo.de.lara.guarch@intel.com \
/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).