* [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures
@ 2017-05-17 18:03 Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface Charles (Chas) Williams
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Charles (Chas) Williams @ 2017-05-17 18:03 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
Fixes: 1b93c2aa81b4 ("net/af_packet: add interface name to internals")
Signed-off-by: Chas Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index a03966a..ce4dc07 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -630,6 +630,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
goto error_early;
}
(*internals)->if_name = strdup(pair->value);
+ if ((*internals)->if_name == NULL)
+ goto error_early;
(*internals)->if_index = ifr.ifr_ifindex;
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface
2017-05-17 18:03 [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Charles (Chas) Williams
@ 2017-05-17 18:03 ` Charles (Chas) Williams
2017-05-22 9:39 ` Ferruh Yigit
2017-05-17 18:03 ` [dpdk-dev] [PATCH 3/3] net/af_packet: fix packet bytes counting Charles (Chas) Williams
2017-05-23 9:50 ` [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Ferruh Yigit
2 siblings, 1 reply; 6+ messages in thread
From: Charles (Chas) Williams @ 2017-05-17 18:03 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
Provide an accessor for the name of the underlying linux interface
used by the AF_PACKET-based interface.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/Makefile | 2 +
drivers/net/af_packet/rte_eth_af_packet.c | 17 +++++++
drivers/net/af_packet/rte_eth_af_packet.h | 55 ++++++++++++++++++++++
.../net/af_packet/rte_pmd_af_packet_version.map | 6 +++
4 files changed, 80 insertions(+)
create mode 100644 drivers/net/af_packet/rte_eth_af_packet.h
diff --git a/drivers/net/af_packet/Makefile b/drivers/net/af_packet/Makefile
index 70d517c..5ea058c 100644
--- a/drivers/net/af_packet/Makefile
+++ b/drivers/net/af_packet/Makefile
@@ -50,4 +50,6 @@ CFLAGS += $(WERROR_FLAGS)
#
SRCS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += rte_eth_af_packet.c
+SYMLINK-y-include += rte_eth_af_packet.h
+
include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index ce4dc07..6927f70 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -43,6 +43,8 @@
#include <rte_kvargs.h>
#include <rte_vdev.h>
+#include "rte_eth_af_packet.h"
+
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <arpa/inet.h>
@@ -125,6 +127,21 @@ static struct rte_eth_link pmd_link = {
.link_autoneg = ETH_LINK_SPEED_AUTONEG
};
+int
+rte_af_packet_get_ifname(uint8_t port, char *buf, size_t len)
+{
+ struct rte_eth_dev *dev;
+ struct pmd_internals *internals;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+ internals = dev->data->dev_private;
+ snprintf(buf, len, "%s", internals->if_name);
+
+ return 0;
+}
+
static uint16_t
eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
diff --git a/drivers/net/af_packet/rte_eth_af_packet.h b/drivers/net/af_packet/rte_eth_af_packet.h
new file mode 100644
index 0000000..c5276f5
--- /dev/null
+++ b/drivers/net/af_packet/rte_eth_af_packet.h
@@ -0,0 +1,55 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) 2017 Brocade Communications Systems, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_ETH_AF_PACKET_H_
+#define _RTE_ETH_AF_PACKET_H_
+
+#include <rte_ethdev.h>
+
+/**
+ * Get the name of the underlying kernel interface assocated
+ * with this AF_PACKET device.
+ *
+ * @param port
+ * The port identifier of the AF_PACKET device.
+ * @param buf
+ * The buffer to stored the queried ifname
+ * @param len
+ * The length of buf
+ *
+ * @return
+ * 0 on success, -1 on failure
+ */
+int rte_af_packet_get_ifname(uint8_t port, char *buf, size_t len);
+
+#endif /* _RTE_ETH_AF_PACKET_H_ */
diff --git a/drivers/net/af_packet/rte_pmd_af_packet_version.map b/drivers/net/af_packet/rte_pmd_af_packet_version.map
index ef35398..2231699 100644
--- a/drivers/net/af_packet/rte_pmd_af_packet_version.map
+++ b/drivers/net/af_packet/rte_pmd_af_packet_version.map
@@ -2,3 +2,9 @@ DPDK_2.0 {
local: *;
};
+
+DPDK_17.08 {
+ global:
+
+ rte_af_packet_get_ifname;
+};
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 3/3] net/af_packet: fix packet bytes counting
2017-05-17 18:03 [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface Charles (Chas) Williams
@ 2017-05-17 18:03 ` Charles (Chas) Williams
2017-05-23 9:50 ` [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Charles (Chas) Williams @ 2017-05-17 18:03 UTC (permalink / raw)
To: dev; +Cc: linville, Charles (Chas) Williams
On error, we also need to zero the bytes transmitted.
Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 6927f70..e456836 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -269,8 +269,11 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
}
/* kick-off transmits */
- if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1)
- num_tx = 0; /* error sending -- no packets transmitted */
+ if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1) {
+ /* error sending -- no packets transmitted */
+ num_tx = 0;
+ num_tx_bytes = 0;
+ }
pkt_q->framenum = framenum;
pkt_q->tx_pkts += num_tx;
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface
2017-05-17 18:03 ` [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface Charles (Chas) Williams
@ 2017-05-22 9:39 ` Ferruh Yigit
2017-05-22 13:20 ` Charles (Chas) Williams
0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2017-05-22 9:39 UTC (permalink / raw)
To: Charles (Chas) Williams, dev; +Cc: linville
Hi Chas,
On 5/17/2017 7:03 PM, Charles (Chas) Williams wrote:
> Provide an accessor for the name of the underlying linux interface
> used by the AF_PACKET-based interface.
This patch provides a PMD specific API to get PMD internal data
(internals->if_name).
I think we should avoid PMD specific APIs if possible.
internals->if_name is provided by application, as devargs to af_packet
(iface=..), so app already knows port_id -> if_name mapping.
OR
With rte_eth_dev_info_get() af_packet returns the if_index for
underlying interface, it is possible to use if_indextoname() to get ifname.
Because above methods exists to get if_name, I think this API is not
necessary.
>
> Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
<...>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface
2017-05-22 9:39 ` Ferruh Yigit
@ 2017-05-22 13:20 ` Charles (Chas) Williams
0 siblings, 0 replies; 6+ messages in thread
From: Charles (Chas) Williams @ 2017-05-22 13:20 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: linville
On 05/22/2017 05:39 AM, Ferruh Yigit wrote:
> Hi Chas,
>
> On 5/17/2017 7:03 PM, Charles (Chas) Williams wrote:
>> Provide an accessor for the name of the underlying linux interface
>> used by the AF_PACKET-based interface.
>
> This patch provides a PMD specific API to get PMD internal data
> (internals->if_name).
>
> I think we should avoid PMD specific APIs if possible.
>
> internals->if_name is provided by application, as devargs to af_packet
> (iface=..), so app already knows port_id -> if_name mapping.
>
> OR
>
> With rte_eth_dev_info_get() af_packet returns the if_index for
> underlying interface, it is possible to use if_indextoname() to get ifname.
>
> Because above methods exists to get if_name, I think this API is not
> necessary.
I will go this route then.
>>
>> Signed-off-by: Charles (Chas) Williams <ciwillia@brocade.com>
>
> <...>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures
2017-05-17 18:03 [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 3/3] net/af_packet: fix packet bytes counting Charles (Chas) Williams
@ 2017-05-23 9:50 ` Ferruh Yigit
2 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2017-05-23 9:50 UTC (permalink / raw)
To: Charles (Chas) Williams, dev; +Cc: linville
On 5/17/2017 7:03 PM, Charles (Chas) Williams wrote:
> Fixes: 1b93c2aa81b4 ("net/af_packet: add interface name to internals")
>
> Signed-off-by: Chas Williams <ciwillia@brocade.com>
Series applied to dpdk-next-net/master, thanks.
Except patch 2/3, it is removed from patchset.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-23 9:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 18:03 [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 2/3] net/af_packet: add accessor for iface Charles (Chas) Williams
2017-05-22 9:39 ` Ferruh Yigit
2017-05-22 13:20 ` Charles (Chas) Williams
2017-05-17 18:03 ` [dpdk-dev] [PATCH 3/3] net/af_packet: fix packet bytes counting Charles (Chas) Williams
2017-05-23 9:50 ` [dpdk-dev] [PATCH 1/3] net/af_packet: handle strdup() failures 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).