get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/4492/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 4492,
    "url": "https://patches.dpdk.org/api/patches/4492/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/etPan.5540261b.2ae8944a.765@Nicos-MacBook-Pro.local/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<etPan.5540261b.2ae8944a.765@Nicos-MacBook-Pro.local>",
    "list_archive_url": "https://inbox.dpdk.org/dev/etPan.5540261b.2ae8944a.765@Nicos-MacBook-Pro.local",
    "date": "2015-04-29T00:30:19",
    "name": "[dpdk-dev,1/3] pcap: utilize underlying real interface properties",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "a5a525b481ddcb006874c48eefb8f8e2b0117ec1",
    "submitter": {
        "id": 115,
        "url": "https://patches.dpdk.org/api/people/115/?format=api",
        "name": "Nicolás Pernas Maradei",
        "email": "nicolas.pernas.maradei@emutex.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/etPan.5540261b.2ae8944a.765@Nicos-MacBook-Pro.local/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/4492/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/4492/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 0E64FC734;\n\tWed, 29 Apr 2015 02:31:26 +0200 (CEST)",
            "from smtp.digiweb.ie (smtp2.digiweb.ie [83.147.160.14])\n\tby dpdk.org (Postfix) with ESMTP id 9D78AC72C\n\tfor <dev@dpdk.org>; Wed, 29 Apr 2015 02:31:24 +0200 (CEST)",
            "from statler.emutex.com (unknown [92.51.199.138])\n\tby smtp.digiweb.ie (Postfix) with ESMTP id E118B290030;\n\tWed, 29 Apr 2015 01:30:20 +0100 (IST)",
            "from 188-141-82-118.dynamic.upc.ie ([188.141.82.118]\n\thelo=Nicos-MacBook-Pro.local) by statler.emutex.com with esmtpsa\n\t(TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.72) (envelope-from <nicolas.pernas.maradei@emutex.com>)\n\tid 1YnFtM-0004B0-2I; Wed, 29 Apr 2015 01:30:20 +0100"
        ],
        "Date": "Wed, 29 Apr 2015 01:30:19 +0100",
        "From": "=?utf-8?Q?Nicol=C3=A1s_Pernas_Maradei?=\n\t<nicolas.pernas.maradei@emutex.com>",
        "To": "dev@dpdk.org, tero.aho@coriant.com",
        "Message-ID": "<etPan.5540261b.2ae8944a.765@Nicos-MacBook-Pro.local>",
        "X-Mailer": "Airmail (286)",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "Content-Disposition": "inline",
        "X-Content-Filtered-By": "Mailman/MimeDel 2.1.15",
        "Subject": "Re: [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real interface\n\tproperties",
        "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>,\n\t<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>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Hi Tero,\n\nJust a few comments on one of your patches - see inline comments below. Interesting features btw.\n\nNico.\n\n-- \nNicolás Pernas Maradei\n\n\nOn 27 February 2015 at 13:43:14, dev-request@dpdk.org (dev-request@dpdk.org) wrote:\n\nMessage: 5 \nDate: Fri, 27 Feb 2015 15:42:38 +0200 \nFrom: Tero Aho <tero.aho@coriant.com> \nTo: <dev@dpdk.org> \nSubject: [dpdk-dev] [PATCH 1/3] pcap: utilize underlying real \ninterface\tproperties \nMessage-ID: <1425044560-23397-2-git-send-email-tero.aho@coriant.com> \nContent-Type: text/plain \n\nThese changes set pcap interface mac address to the real underlying \ninterface address instead of the default one. Also real interface link \nstatus, speed and duplex are reported when eth_link_update is called \nfor the pcap interface. \n\nSigned-off-by: Tero Aho <tero.aho@coriant.com> \n--- \nlib/librte_pmd_pcap/rte_eth_pcap.c | 51 +++++++++++++++++++++++++++++++++++--- \n1 file changed, 47 insertions(+), 4 deletions(-) \n\n+ cmd.duplex ? ETH_LINK_FULL_DUPLEX : ETH_LINK_HALF_DUPLEX; \n+ } \n+ } \nreturn 0; \n} \n\n@@ -736,11 +763,24 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, \n(*internals)->nb_rx_queues = nb_rx_queues; \n(*internals)->nb_tx_queues = nb_tx_queues; \n\n- if (pair == NULL) \n+ if (pair == NULL) { \n(*internals)->if_index = 0; \n- else \n+ } else { \n+ /* use real inteface mac addr, save name and fd for eth_link_update */ \n(*internals)->if_index = if_nametoindex(pair->value); \n- \n+ (*internals)->if_name = strdup(pair->value); \n+ (*internals)->if_fd = socket(AF_INET, SOCK_DGRAM, 0); \nI 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?\n\nThese would be the files you’d need to open and read to the get the info you are looking for. \n\n# cat /sys/class/net/eth0/address\n# cat /sys/class/net/eth0/duplex\n# cat /sys/class/net/eth0/speed\n\nIn my opinion the code would be cleaner doing it this way. DPDK already manipulates sysfs in other places too. \nWhat do you think?\n\n\n+ if ((*internals)->if_fd != -1) { \n+ struct ifreq ifr; \n+ strncpy(ifr.ifr_name, pair->value, sizeof(ifr.ifr_name)-1); \n+ ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; \nUse snprintf() like before.\n\n\n+ if (!ioctl((*internals)->if_fd, SIOCGIFHWADDR, &ifr)) { \n+ data->mac_addrs = rte_zmalloc_socket(NULL, ETHER_ADDR_LEN, 0, numa_node); \n+ if (data->mac_addrs) \n+ rte_memcpy(data->mac_addrs, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); \n+ } \n+ } \n+ } \npci_dev->numa_node = numa_node; \n\ndata->dev_private = *internals; \n@@ -749,7 +789,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, \ndata->nb_rx_queues = (uint16_t)nb_rx_queues; \ndata->nb_tx_queues = (uint16_t)nb_tx_queues; \ndata->dev_link = pmd_link; \n- data->mac_addrs = &eth_addr; \n+ if (data->mac_addrs == NULL) \n+ data->mac_addrs = &eth_addr; \nstrncpy(data->name, \n(*eth_dev)->data->name, strlen((*eth_dev)->data->name)); \n\n@@ -758,6 +799,8 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, \n(*eth_dev)->pci_dev = pci_dev; \n(*eth_dev)->driver = &rte_pcap_pmd; \n\n+ eth_link_update((*eth_dev), 0); \n+ \nreturn 0; \n\nerror: if (data) \n-- \n1.9.1 \n\n\n============================================================ \nThe information contained in this message may be privileged \nand confidential and protected from disclosure. If the reader \nof this message is not the intended recipient, or an employee \nor agent responsible for delivering this message to the \nintended recipient, you are hereby notified that any reproduction, \ndissemination or distribution of this communication is strictly \nprohibited. If you have received this communication in error, \nplease notify us immediately by replying to the message and \ndeleting it from your computer. Thank you. Coriant-Tellabs \n============================================================ \n\n\n------------------------------ \n\nSubject: Digest Footer \n\n_______________________________________________ \ndev mailing list \ndev@dpdk.org \nhttp://dpdk.org/ml/listinfo/dev \n\n\n------------------------------ \n\nEnd of dev Digest, Vol 29, Issue 99 \n***********************************",
    "diff": "diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c \nindex 5e94930..289af28 100644 \n--- a/lib/librte_pmd_pcap/rte_eth_pcap.c \n+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c \n@@ -43,6 +43,11 @@ \n#include <rte_dev.h> \n\n#include <net/if.h> \n+#include <sys/socket.h> \n+#include <sys/ioctl.h> \n+#include <string.h> \n+#include <linux/ethtool.h> \n+#include <linux/sockios.h> \n\n#include <pcap.h> \n\n@@ -102,6 +107,8 @@ struct pmd_internals { \nunsigned nb_tx_queues; \nint if_index; \nint single_iface; \n+ const char *if_name; \n+ int if_fd; \n}; \n\nconst char *valid_arguments[] = { \n@@ -451,6 +458,26 @@ static int \neth_link_update(struct rte_eth_dev *dev __rte_unused, \n*dev is being used. Remove __rte_unused\n\n\nint wait_to_complete __rte_unused) \n{ \n+ struct ifreq ifr; \n+ struct ethtool_cmd cmd; \n+ struct pmd_internals *internals = dev->data->dev_private; \n+ \n+ if (internals->if_name && (internals->if_fd != -1)) { \n+ /* get link status, speed and duplex from the underlying interface */ \n+ \n+ strncpy(ifr.ifr_name, internals->if_name, sizeof(ifr.ifr_name)-1); \n+ ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; \nUse snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), “%s”, internals->if_name) instead. It’s safer and cleaner.\n\n\n+ if (!ioctl(internals->if_fd, SIOCGIFFLAGS, &ifr)) \n+ dev->data->dev_link.link_status = (ifr.ifr_flags & IFF_UP) ? 1 : 0; \n+ \n+ cmd.cmd = ETHTOOL_GSET; \n+ ifr.ifr_data = (void *)&cmd; \n+ if (!ioctl(internals->if_fd, SIOCETHTOOL, &ifr)) { \n+ dev->data->dev_link.link_speed = ethtool_cmd_speed(&cmd); \n+ dev->data->dev_link.link_duplex = \n",
    "prefixes": [
        "dpdk-dev",
        "1/3"
    ]
}