DPDK patches and discussions
 help / color / mirror / Atom feed
* Re: [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface properties
@ 2015-04-29  0:30 Nicolás Pernas Maradei
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolás Pernas Maradei @ 2015-04-29  0:30 UTC (permalink / raw)
  To: dev, tero.aho

Hi Tero,

Just a few comments on one of your patches - see inline comments below. Interesting features btw.

Nico.

-- 
Nicolás Pernas Maradei


On 27 February 2015 at 13:43:14, dev-request@dpdk.org (dev-request@dpdk.org) wrote:

Message: 5 
Date: Fri, 27 Feb 2015 15:42:38 +0200 
From: Tero Aho <tero.aho@coriant.com> 
To: <dev@dpdk.org> 
Subject: [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real 
interface	properties 
Message-ID: <1425044560-23397-2-git-send-email-tero.aho@coriant.com> 
Content-Type: text/plain 

These changes set pcap interface mac address to the real underlying 
interface address instead of the default one. Also real interface link 
status, speed and duplex are reported when eth_link_update is called 
for the pcap interface. 

Signed-off-by: Tero Aho <tero.aho@coriant.com> 
--- 
lib/librte_pmd_pcap/rte_eth_pcap.c | 51 +++++++++++++++++++++++++++++++++++--- 
1 file changed, 47 insertions(+), 4 deletions(-) 

diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c 
index 5e94930..289af28 100644 
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c 
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c 
@@ -43,6 +43,11 @@ 
#include <rte_dev.h> 

#include <net/if.h> 
+#include <sys/socket.h> 
+#include <sys/ioctl.h> 
+#include <string.h> 
+#include <linux/ethtool.h> 
+#include <linux/sockios.h> 

#include <pcap.h> 

@@ -102,6 +107,8 @@ struct pmd_internals { 
unsigned nb_tx_queues; 
int if_index; 
int single_iface; 
+ const char *if_name; 
+ int if_fd; 
}; 

const char *valid_arguments[] = { 
@@ -451,6 +458,26 @@ static int 
eth_link_update(struct rte_eth_dev *dev __rte_unused, 
*dev is being used. Remove __rte_unused


int wait_to_complete __rte_unused) 
{ 
+ struct ifreq ifr; 
+ struct ethtool_cmd cmd; 
+ struct pmd_internals *internals = dev->data->dev_private; 
+ 
+ if (internals->if_name && (internals->if_fd != -1)) { 
+ /* get link status, speed and duplex from the underlying interface */ 
+ 
+ strncpy(ifr.ifr_name, internals->if_name, sizeof(ifr.ifr_name)-1); 
+ ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; 
Use snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), “%s”, internals->if_name) instead. It’s safer and cleaner.


+ if (!ioctl(internals->if_fd, SIOCGIFFLAGS, &ifr)) 
+ dev->data->dev_link.link_status = (ifr.ifr_flags & IFF_UP) ? 1 : 0; 
+ 
+ cmd.cmd = ETHTOOL_GSET; 
+ ifr.ifr_data = (void *)&cmd; 
+ if (!ioctl(internals->if_fd, SIOCETHTOOL, &ifr)) { 
+ dev->data->dev_link.link_speed = ethtool_cmd_speed(&cmd); 
+ dev->data->dev_link.link_duplex = 
+ cmd.duplex ? ETH_LINK_FULL_DUPLEX : ETH_LINK_HALF_DUPLEX; 
+ } 
+ } 
return 0; 
} 

@@ -736,11 +763,24 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, 
(*internals)->nb_rx_queues = nb_rx_queues; 
(*internals)->nb_tx_queues = nb_tx_queues; 

- if (pair == NULL) 
+ if (pair == NULL) { 
(*internals)->if_index = 0; 
- else 
+ } else { 
+ /* use real inteface mac addr, save name and fd for eth_link_update */ 
(*internals)->if_index = if_nametoindex(pair->value); 
+ (*internals)->if_name = strdup(pair->value); 
+ (*internals)->if_fd = socket(AF_INET, SOCK_DGRAM, 0); 
I see you are using a socket and ioctl calls to get the info you need from the interface. I’m not a big fan of opening a socket at this point just to get some parameters of the NIC. I’d rather reading those from sysfs. Is there a reason why you’d prefer to open a socket?

These would be the files you’d need to open and read to the get the info you are looking for. 

# cat /sys/class/net/eth0/address
# cat /sys/class/net/eth0/duplex
# cat /sys/class/net/eth0/speed

In my opinion the code would be cleaner doing it this way. DPDK already manipulates sysfs in other places too. 
What do you think?


+ if ((*internals)->if_fd != -1) { 
+ struct ifreq ifr; 
+ strncpy(ifr.ifr_name, pair->value, sizeof(ifr.ifr_name)-1); 
+ ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; 
Use snprintf() like before.


+ if (!ioctl((*internals)->if_fd, SIOCGIFHWADDR, &ifr)) { 
+ data->mac_addrs = rte_zmalloc_socket(NULL, ETHER_ADDR_LEN, 0, numa_node); 
+ if (data->mac_addrs) 
+ rte_memcpy(data->mac_addrs, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); 
+ } 
+ } 
+ } 
pci_dev->numa_node = numa_node; 

data->dev_private = *internals; 
@@ -749,7 +789,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, 
data->nb_rx_queues = (uint16_t)nb_rx_queues; 
data->nb_tx_queues = (uint16_t)nb_tx_queues; 
data->dev_link = pmd_link; 
- data->mac_addrs = &eth_addr; 
+ if (data->mac_addrs == NULL) 
+ data->mac_addrs = &eth_addr; 
strncpy(data->name, 
(*eth_dev)->data->name, strlen((*eth_dev)->data->name)); 

@@ -758,6 +799,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, 
(*eth_dev)->pci_dev = pci_dev; 
(*eth_dev)->driver = &rte_pcap_pmd; 

+ eth_link_update((*eth_dev), 0); 
+ 
return 0; 

error: if (data) 
-- 
1.9.1 


============================================================ 
The information contained in this message may be privileged 
and confidential and protected from disclosure. If the reader 
of this message is not the intended recipient, or an employee 
or agent responsible for delivering this message to the 
intended recipient, you are hereby notified that any reproduction, 
dissemination or distribution of this communication is strictly 
prohibited. If you have received this communication in error, 
please notify us immediately by replying to the message and 
deleting it from your computer. Thank you. Coriant-Tellabs 
============================================================ 


------------------------------ 

Subject: Digest Footer 

_______________________________________________ 
dev mailing list 
dev@dpdk.org 
http://dpdk.org/ml/listinfo/dev 


------------------------------ 

End of dev Digest, Vol 29, Issue 99 
*********************************** 
From rkerur@gmail.com  Wed Apr 29 03:15:55 2015
Return-Path: <rkerur@gmail.com>
Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com
 [209.85.214.177]) by dpdk.org (Postfix) with ESMTP id 5986EC740
 for <dev@dpdk.org>; Wed, 29 Apr 2015 03:15:55 +0200 (CEST)
Received: by obcux3 with SMTP id ux3so9679357obc.2
 for <dev@dpdk.org>; Tue, 28 Apr 2015 18:15:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s 120113;
 h=mime-version:date:message-id:subject:from:to:content-type;
 bh=MZ4S6lBJpl67DyjGKoevJH7hj1P2/ahlV1nfxWJ6CPw=;
 b=MlHdvUs4IlMw5URRnd8FCPs1PxkZyuqSk6Wem3+AbXe0sX3eOHd3SDgmk2/oSL9TPc
 Lnrs+5BGw+bS9WPki9UN2tg6QokPszOxpfxfodEpqa0PgWFeRZbRrqE5fEwJbcFNkeyD
 E1SatooWejmZst7JVyACc+lnno8tm4KVhebLtnX7uCsUzrRZ4cTIwY/S26NhCSpUzDjO
 HU4BQgzDMMShyYavYUeK8TIaRfVz3EnQs1yBeEJFNZrDvu8fucl4CKGofmJHu94a1+cs
 eIO0DM1sqnBQstBzuVH21PkmBmn2f2CgZ04G0HzmanmWvwhYi+fEnskb12ZJ1fnE/Xs2
 eH0w=MIME-Version: 1.0
X-Received: by 10.182.39.168 with SMTP id q8mr16869793obk.23.1430270153684;
 Tue, 28 Apr 2015 18:15:53 -0700 (PDT)
Received: by 10.202.179.195 with HTTP; Tue, 28 Apr 2015 18:15:53 -0700 (PDT)
Date: Tue, 28 Apr 2015 18:15:53 -0700
Message-ID: <CAFb4SLBGcR1EHL5FkJ7r6-7mqWR9UJ7GLD2cm18SJ8AuoWu_Og@mail.gmail.com>
From: Ravi Kerur <rkerur@gmail.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: [dpdk-dev] gmake test on freeBSD
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Apr 2015 01:15:55 -0000

DPDK team,

Is there a automated tests to run on freeBSD similar to Linux (make test).

I ran "gmake test T=x86_64-native-bsdapp-clang CC=clang" I get following
output

/usr/home/rkerur/dpdk-validate-abi-1/dpdk/build/app/test -c f -n 4

Test name                      Test result                      Test
Total
===============================================================================Start group_1:                 Fail [Can't run]              [00m 00s]
Timer autotest:                Fail [Can't run]              [00m 00s]
Debug autotest:                Fail [Can't run]              [00m 00s]
Errno autotest:                Fail [Can't run]              [00m 00s]
Meter autotest:                Fail [Can't run]              [00m 00s]
Common autotest:               Fail [Can't run]              [00m 00s]
Dump log history:              Fail [Can't run]              [00m 00s]
...
Start memcpy_perf:             Fail [No prompt]              [00m 00s]
Memcpy performance autotest:   Fail [No prompt]              [00m 00s] [00m
01s]
Start hash_perf:               Fail [No prompt]              [00m 00s]
Hash performance autotest:     Fail [No prompt]              [00m 00s] [00m
01s]
Start power:                   Fail [No prompt]              [00m 00s]
Power autotest:                Fail [No prompt]              [00m 00s] [00m
01s]
...

I have contigmem and nic_uio installed. I know some applications are
linuxapp specific but wanted to know if there is a similar automated test
tool like Linux?

Thanks,
Ravi

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [dpdk-dev] [PATCH 0/3] pcap pmd improvements
@ 2015-02-27 13:42 Tero Aho
  2015-02-27 13:42 ` [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface properties Tero Aho
  0 siblings, 1 reply; 3+ messages in thread
From: Tero Aho @ 2015-02-27 13:42 UTC (permalink / raw)
  To: dev

We have found it convenient to use pcap interfaces in early development
when speed does not matter. However, pcap interfaces use fixed values
for some properties like link status which makes it hard to simulate
certain conditions.

Here's series of small improvements we have originally used on top
of v1.7.0 (now rebased to current master).

Tero Aho (3):
  pcap: utilize underlying real interface properties
  pcap: add support for jumbo frames
  pcap: add byte and error counters into statistics

 lib/librte_pmd_pcap/rte_eth_pcap.c | 176 +++++++++++++++++++++++++++++++------
 1 file changed, 151 insertions(+), 25 deletions(-)

--
1.9.1


============================================================
The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader
of this message is not the intended recipient, or an employee
or agent responsible for delivering this message to the
intended recipient, you are hereby notified that any reproduction,
dissemination or distribution of this communication is strictly
prohibited. If you have received this communication in error,
please notify us immediately by replying to the message and
deleting it from your computer. Thank you. Coriant-Tellabs
============================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-29  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29  0:30 [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface properties Nicolás Pernas Maradei
  -- strict thread matches above, loose matches on Subject: below --
2015-02-27 13:42 [dpdk-dev] [PATCH 0/3] pcap pmd improvements Tero Aho
2015-02-27 13:42 ` [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface properties Tero Aho
2015-04-28 13:49   ` Mcnamara, John

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).