* [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals
@ 2017-01-05 13:53 Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 2/4] net/af_packet: add support to change mtu Charles (Chas) Williams
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Charles (Chas) Williams @ 2017-01-05 13:53 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
This will be used by later changes to determine the underlying linux
interface.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 17b4ffe..4ef61a2 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -99,6 +99,7 @@ struct pmd_internals {
unsigned nb_queues;
int if_index;
+ char *if_name;
struct ether_addr eth_addr;
struct tpacket_req req;
@@ -532,6 +533,7 @@ rte_pmd_init_internals(const char *name,
name);
goto error_early;
}
+ (*internals)->if_name = strdup(pair->value);
(*internals)->if_index = ifr.ifr_ifindex;
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
@@ -723,6 +725,7 @@ rte_pmd_init_internals(const char *name,
((*internals)->rx_queue[q].sockfd != qsockfd))
close((*internals)->rx_queue[q].sockfd);
}
+ free((*internals)->if_name);
rte_free(*internals);
error_early:
rte_free(data);
@@ -891,6 +894,7 @@ rte_pmd_af_packet_remove(const char *name)
rte_free(internals->rx_queue[q].rd);
rte_free(internals->tx_queue[q].rd);
}
+ free(internals->if_name);
rte_free(eth_dev->data->dev_private);
rte_free(eth_dev->data);
--
2.1.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2 2/4] net/af_packet: add support to change mtu
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
@ 2017-01-05 13:53 ` Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 3/4] net/af_packet: promisicuous support Charles (Chas) Williams
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Charles (Chas) Williams @ 2017-01-05 13:53 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
The underlying linux device's MTU is changed subject to the frame size
limitations during device creation.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 4ef61a2..a700b96 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -412,12 +412,41 @@ eth_tx_queue_setup(struct rte_eth_dev *dev,
return 0;
}
+static int
+eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
+{
+ struct pmd_internals *internals = dev->data->dev_private;
+ struct ifreq ifr = { .ifr_mtu = mtu };
+ int ret;
+ int s;
+ unsigned int data_size = internals->req.tp_frame_size -
+ TPACKET2_HDRLEN -
+ sizeof(struct sockaddr_ll);
+
+ if (mtu > data_size)
+ return -EINVAL;
+
+ s = socket(PF_INET, SOCK_DGRAM, 0);
+ if (s < 0)
+ return -EINVAL;
+
+ strncpy(ifr.ifr_name, internals->if_name, IFNAMSIZ);
+ ret = ioctl(s, SIOCSIFMTU, &ifr);
+ close(s);
+
+ if (ret < 0)
+ return -EINVAL;
+
+ return 0;
+}
+
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
.dev_stop = eth_dev_stop,
.dev_close = eth_dev_close,
.dev_configure = eth_dev_configure,
.dev_infos_get = eth_dev_info,
+ .mtu_set = eth_dev_mtu_set,
.rx_queue_setup = eth_rx_queue_setup,
.tx_queue_setup = eth_tx_queue_setup,
.rx_queue_release = eth_queue_release,
--
2.1.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2 3/4] net/af_packet: promisicuous support
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 2/4] net/af_packet: add support to change mtu Charles (Chas) Williams
@ 2017-01-05 13:53 ` Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 4/4] net/af_packet: add 802.1Q (VLAN) support Charles (Chas) Williams
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Charles (Chas) Williams @ 2017-01-05 13:53 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
Add promiscuous support to the AF_PACKET PMD. The underlying linux
device's IF_PROMISC flag is toggled to enable or disable.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 39 +++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index a700b96..6aa8132 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -440,6 +440,43 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
return 0;
}
+static void
+eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
+{
+ struct ifreq ifr;
+ int s;
+
+ s = socket(PF_INET, SOCK_DGRAM, 0);
+ if (s < 0)
+ return;
+
+ strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
+ if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
+ goto out;
+ ifr.ifr_flags &= mask;
+ ifr.ifr_flags |= flags;
+ if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0)
+ goto out;
+out:
+ close(s);
+}
+
+static void
+eth_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+ struct pmd_internals *internals = dev->data->dev_private;
+
+ eth_dev_change_flags(internals->if_name, IFF_PROMISC, ~0);
+}
+
+static void
+eth_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+ struct pmd_internals *internals = dev->data->dev_private;
+
+ eth_dev_change_flags(internals->if_name, 0, ~IFF_PROMISC);
+}
+
static const struct eth_dev_ops ops = {
.dev_start = eth_dev_start,
.dev_stop = eth_dev_stop,
@@ -447,6 +484,8 @@ static const struct eth_dev_ops ops = {
.dev_configure = eth_dev_configure,
.dev_infos_get = eth_dev_info,
.mtu_set = eth_dev_mtu_set,
+ .promiscuous_enable = eth_dev_promiscuous_enable,
+ .promiscuous_disable = eth_dev_promiscuous_disable,
.rx_queue_setup = eth_rx_queue_setup,
.tx_queue_setup = eth_tx_queue_setup,
.rx_queue_release = eth_queue_release,
--
2.1.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2 4/4] net/af_packet: add 802.1Q (VLAN) support
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 2/4] net/af_packet: add support to change mtu Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 3/4] net/af_packet: promisicuous support Charles (Chas) Williams
@ 2017-01-05 13:53 ` Charles (Chas) Williams
2017-01-05 14:04 ` [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Ferruh Yigit
2017-01-16 14:31 ` Ferruh Yigit
4 siblings, 0 replies; 7+ messages in thread
From: Charles (Chas) Williams @ 2017-01-05 13:53 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
AF_PACKET has some flags to check on the receive side for 802.1Q
information. If present, we copy into the mbuf. For transmit, we
insert any 802.1Q information into the packet before copying to the ring.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 6aa8132..ee51c17 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -161,6 +161,12 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
pbuf = (uint8_t *) ppd + ppd->tp_mac;
memcpy(rte_pktmbuf_mtod(mbuf, void *), pbuf, rte_pktmbuf_data_len(mbuf));
+ /* check for vlan info */
+ if (ppd->tp_status & TP_STATUS_VLAN_VALID) {
+ mbuf->vlan_tci = ppd->tp_vlan_tci;
+ mbuf->ol_flags |= (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED);
+ }
+
/* release incoming frame and advance ring buffer */
ppd->tp_status = TP_STATUS_KERNEL;
if (++framenum >= framecount)
@@ -214,6 +220,14 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
continue;
}
+ /* insert vlan info if necessary */
+ if (mbuf->ol_flags & PKT_TX_VLAN_PKT) {
+ if (rte_vlan_insert(&mbuf)) {
+ rte_pktmbuf_free(mbuf);
+ continue;
+ }
+ }
+
/* point at the next incoming frame */
if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
(poll(&pfd, 1, -1) < 0))
--
2.1.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
` (2 preceding siblings ...)
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 4/4] net/af_packet: add 802.1Q (VLAN) support Charles (Chas) Williams
@ 2017-01-05 14:04 ` Ferruh Yigit
2017-01-16 14:31 ` Ferruh Yigit
4 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2017-01-05 14:04 UTC (permalink / raw)
To: Charles (Chas) Williams, dev; +Cc: linville
On 1/5/2017 1:53 PM, Charles (Chas) Williams wrote:
> This will be used by later changes to determine the underlying linux
> interface.
>
> Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
Hi Charles,
Independent from the patch content,
it will be useful if you can send new patchset as reply to previous one,
this way all patches will be in same mail thread, this will help to
trace/review them, also it will be easier to find them in mail archive
in the future.
Another thing is, if you can add a version diff in the comment log,
after "---", that helps others to understand what has been changed in
this new version.
Thanks,
ferruh
<...>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
` (3 preceding siblings ...)
2017-01-05 14:04 ` [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Ferruh Yigit
@ 2017-01-16 14:31 ` Ferruh Yigit
2017-01-16 14:35 ` Ferruh Yigit
4 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2017-01-16 14:31 UTC (permalink / raw)
To: Charles (Chas) Williams, dev; +Cc: linville
On 1/5/2017 1:53 PM, Charles (Chas) Williams wrote:
> This will be used by later changes to determine the underlying linux
> interface.
>
> Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
Series Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals
2017-01-16 14:31 ` Ferruh Yigit
@ 2017-01-16 14:35 ` Ferruh Yigit
0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2017-01-16 14:35 UTC (permalink / raw)
To: Charles (Chas) Williams, dev; +Cc: linville
On 1/16/2017 2:31 PM, Ferruh Yigit wrote:
> On 1/5/2017 1:53 PM, Charles (Chas) Williams wrote:
>> This will be used by later changes to determine the underlying linux
>> interface.
>>
>> Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
>
> Series Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-16 14:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05 13:53 [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 2/4] net/af_packet: add support to change mtu Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 3/4] net/af_packet: promisicuous support Charles (Chas) Williams
2017-01-05 13:53 ` [dpdk-dev] [PATCH v2 4/4] net/af_packet: add 802.1Q (VLAN) support Charles (Chas) Williams
2017-01-05 14:04 ` [dpdk-dev] [PATCH v2 1/4] net/af_packet: add iface name to internals Ferruh Yigit
2017-01-16 14:31 ` Ferruh Yigit
2017-01-16 14:35 ` Ferruh Yigit
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).