From: Pascal Mazon <pascal.mazon@6wind.com>
To: keith.wiles@intel.com, ferruh.yigit@intel.com
Cc: dev@dpdk.org, Pascal Mazon <pascal.mazon@6wind.com>
Subject: [dpdk-dev] [PATCH v5 3/8] net/tap: add MAC address management
Date: Wed, 15 Mar 2017 15:48:14 +0100 [thread overview]
Message-ID: <869fb3ba9da08763fe0fdbb82e9083a0adceab48.1489589167.git.pascal.mazon@6wind.com> (raw)
In-Reply-To: <cover.1489589167.git.pascal.mazon@6wind.com>
As soon as the netdevice is created, update pmd->mac_addr with its
actual MAC address.
Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
doc/guides/nics/features/tap.ini | 1 +
drivers/net/tap/rte_eth_tap.c | 39 +++++++++++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/doc/guides/nics/features/tap.ini b/doc/guides/nics/features/tap.ini
index f4aca6921ddc..d9b47a003654 100644
--- a/doc/guides/nics/features/tap.ini
+++ b/doc/guides/nics/features/tap.ini
@@ -9,6 +9,7 @@ Jumbo frame = Y
Promiscuous mode = Y
Allmulticast mode = Y
Basic stats = Y
+Unicast MAC filter = Y
Other kdrv = Y
ARMv7 = Y
ARMv8 = Y
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 50a07249dff2..2cf8203ba24e 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -127,6 +127,10 @@ tap_trigger_cb(int sig __rte_unused)
tap_trigger = (tap_trigger + 1) | 0x80000000;
}
+static int
+tap_ioctl(struct pmd_internals *pmd, unsigned long request,
+ struct ifreq *ifr, int set);
+
/* Tun/Tap allocation routine
*
* name is the number of the interface to use, unless NULL to take the host
@@ -229,13 +233,12 @@ tun_alloc(struct pmd_internals *pmd, uint16_t qid)
}
if (qid == 0) {
- if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
- RTE_LOG(ERR, PMD, "ioctl failed (SIOCGIFHWADDR) (%s)\n",
- ifr.ifr_name);
- goto error;
- }
+ struct ifreq ifr;
- rte_memcpy(&pmd->eth_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
+ if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0) < 0)
+ goto error;
+ rte_memcpy(&pmd->eth_addr, ifr.ifr_hwaddr.sa_data,
+ ETHER_ADDR_LEN);
}
return fd;
@@ -345,6 +348,9 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
else
ifr->ifr_flags &= ~req_flags;
break;
+ case SIOCGIFHWADDR:
+ case SIOCSIFHWADDR:
+ break;
default:
RTE_LOG(WARNING, PMD, "%s: ioctl() called with wrong arg\n",
pmd->name);
@@ -547,6 +553,26 @@ tap_allmulti_disable(struct rte_eth_dev *dev)
tap_ioctl(pmd, SIOCSIFFLAGS, &ifr, 0);
}
+
+static void
+tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
+{
+ struct pmd_internals *pmd = dev->data->dev_private;
+ struct ifreq ifr;
+
+ if (is_zero_ether_addr(mac_addr)) {
+ RTE_LOG(ERR, PMD, "%s: can't set an empty MAC address\n",
+ dev->data->name);
+ return;
+ }
+
+ ifr.ifr_hwaddr.sa_family = AF_LOCAL;
+ rte_memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, ETHER_ADDR_LEN);
+ if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 1) < 0)
+ return;
+ rte_memcpy(&pmd->eth_addr, mac_addr, ETHER_ADDR_LEN);
+}
+
static int
tap_setup_queue(struct rte_eth_dev *dev,
struct pmd_internals *internals,
@@ -682,6 +708,7 @@ static const struct eth_dev_ops ops = {
.promiscuous_disable = tap_promisc_disable,
.allmulticast_enable = tap_allmulti_enable,
.allmulticast_disable = tap_allmulti_disable,
+ .mac_addr_set = tap_mac_set,
.stats_get = tap_stats_get,
.stats_reset = tap_stats_reset,
};
--
2.8.0.rc0
next prev parent reply other threads:[~2017-03-15 14:51 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 9:46 [dpdk-dev] [PATCH 0/6] net/tap: add additional management ops Pascal Mazon
2017-03-03 9:46 ` [dpdk-dev] [PATCH 1/6] net/tap: add MAC address " Pascal Mazon
2017-03-03 9:46 ` [dpdk-dev] [PATCH 2/6] net/tap: add speed capabilities Pascal Mazon
2017-03-03 15:27 ` Wiles, Keith
2017-03-06 13:58 ` Pascal Mazon
2017-03-06 14:38 ` Wiles, Keith
2017-03-03 9:46 ` [dpdk-dev] [PATCH 3/6] net/tap: add multicast addresses management Pascal Mazon
2017-03-03 9:46 ` [dpdk-dev] [PATCH 4/6] net/tap: add MTU management Pascal Mazon
2017-03-03 15:23 ` Wiles, Keith
2017-03-06 13:59 ` Pascal Mazon
2017-03-03 9:46 ` [dpdk-dev] [PATCH 5/6] net/tap: add packet type management Pascal Mazon
2017-03-03 15:31 ` Wiles, Keith
2017-03-06 14:10 ` Pascal Mazon
2017-03-06 14:46 ` Wiles, Keith
2017-03-03 9:46 ` [dpdk-dev] [PATCH 6/6] net/tap: add flow control management Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 0/6] net/tap: add additional management ops Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 1/6] net/tap: add MAC address " Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 2/6] net/tap: add speed capabilities Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 3/6] net/tap: add multicast addresses management Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 4/6] net/tap: add MTU management Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 5/6] net/tap: add packet type management Pascal Mazon
2017-03-06 16:31 ` [dpdk-dev] [PATCH v2 6/6] net/tap: add flow control management Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 0/6] net/tap: add additional management ops Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 0/8] " Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 1/8] net/tap: remove wrong IFF_NOARP flags Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 2/8] net/tap: refactor ioctl calls Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 3/8] net/tap: add MAC address management Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 4/8] net/tap: add MTU management Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 5/8] net/tap: add speed capabilities Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 6/8] net/tap: add multicast addresses management Pascal Mazon
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 7/8] net/tap: add packet type management Pascal Mazon
2017-03-15 13:35 ` Ferruh Yigit
2017-03-15 13:44 ` Pascal Mazon
2017-03-15 14:31 ` Ferruh Yigit
2017-03-15 13:42 ` Ferruh Yigit
2017-03-14 8:22 ` [dpdk-dev] [PATCH v4 8/8] net/tap: add flow control management Pascal Mazon
2017-03-15 13:43 ` [dpdk-dev] [PATCH v4 0/8] net/tap: add additional management ops Ferruh Yigit
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 " Pascal Mazon
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 1/8] net/tap: remove wrong IFF_NOARP flags Pascal Mazon
2017-03-15 21:37 ` Wiles, Keith
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 2/8] net/tap: refactor ioctl calls Pascal Mazon
2017-03-15 14:48 ` Pascal Mazon [this message]
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 4/8] net/tap: add MTU management Pascal Mazon
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 5/8] net/tap: add speed capabilities Pascal Mazon
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 6/8] net/tap: add multicast addresses management Pascal Mazon
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 7/8] net/tap: add packet type management Pascal Mazon
2017-03-15 14:48 ` [dpdk-dev] [PATCH v5 8/8] net/tap: add flow control management Pascal Mazon
2017-03-15 16:46 ` [dpdk-dev] [PATCH v5 0/8] net/tap: add additional management ops Ferruh Yigit
2017-03-15 21:44 ` Wiles, Keith
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 1/6] net/tap: add MAC address " Pascal Mazon
2017-03-09 14:05 ` Ferruh Yigit
2017-03-10 9:01 ` Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 2/6] net/tap: add speed capabilities Pascal Mazon
2017-03-09 14:18 ` Ferruh Yigit
2017-03-09 14:36 ` Wiles, Keith
2017-03-09 16:05 ` Ferruh Yigit
2017-03-10 9:03 ` Pascal Mazon
2017-03-10 9:11 ` Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 3/6] net/tap: add multicast addresses management Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 4/6] net/tap: add MTU management Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 5/6] net/tap: add packet type management Pascal Mazon
2017-03-09 14:26 ` Ferruh Yigit
2017-03-10 12:34 ` Pascal Mazon
2017-03-07 16:31 ` [dpdk-dev] [PATCH v3 6/6] net/tap: add flow control management Pascal Mazon
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=869fb3ba9da08763fe0fdbb82e9083a0adceab48.1489589167.git.pascal.mazon@6wind.com \
--to=pascal.mazon@6wind.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=keith.wiles@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).