get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 89514,
    "url": "https://patches.dpdk.org/api/patches/89514/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210318223526.168614-4-maxime.coquelin@redhat.com/",
    "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": "<20210318223526.168614-4-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210318223526.168614-4-maxime.coquelin@redhat.com",
    "date": "2021-03-18T22:35:26",
    "name": "[RFC,3/3] net/virtio: add MAC device config getter and setter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b89c39019f642a14f91ebc7c31fd763c6849ac9b",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210318223526.168614-4-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 15780,
            "url": "https://patches.dpdk.org/api/series/15780/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=15780",
            "date": "2021-03-18T22:35:23",
            "name": "net/virtio: add vdpa device config support",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/15780/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/89514/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/89514/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 626DFA0561;\n\tThu, 18 Mar 2021 23:35:59 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id B5434140F9C;\n\tThu, 18 Mar 2021 23:35:47 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 5AD32140F99\n for <dev@dpdk.org>; Thu, 18 Mar 2021 23:35:46 +0100 (CET)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-122-QPFTtOlZOQyYLG1LmVyvzg-1; Thu, 18 Mar 2021 18:35:44 -0400",
            "from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com\n [10.5.11.12])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2457F83DD21;\n Thu, 18 Mar 2021 22:35:43 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.36.110.14])\n by smtp.corp.redhat.com (Postfix) with ESMTP id CC36E60C13;\n Thu, 18 Mar 2021 22:35:41 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1616106945;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=M4+GfLJFoQa0SMWDSuzOaGwgpTTndCYzrhCQ+SPW9Pg=;\n b=JTRDiKAuk8jRQc93BWd4cw7pLfmAbbqX7u6LYagSmfcVUoT2e39xnoM9nIXiN/PrMAz2xk\n Sa/8lYbMn+sF/En4ClrufmQxGK4i8ZprM7IMVei+5aUdaTJcEA2Hy4mvIKXc/WPTaj6C52\n aOWvhepjUt60Vljzlu5p6DFlR57i1HY=",
        "X-MC-Unique": "QPFTtOlZOQyYLG1LmVyvzg-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, amorenoz@redhat.com,\n david.marchand@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Thu, 18 Mar 2021 23:35:26 +0100",
        "Message-Id": "<20210318223526.168614-4-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20210318223526.168614-1-maxime.coquelin@redhat.com>",
        "References": "<20210318223526.168614-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [RFC 3/3] net/virtio: add MAC device config getter and\n setter",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch uses the new device config ops to get and set\nthe MAC address if supported.\n\nIf a valid MAC address is passed as devarg of the\nVirtio-user PMD, the driver will try to store it in the\ndevice config space. Otherwise the one provided in\nthe device config space will be used, if available.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n .../net/virtio/virtio_user/virtio_user_dev.c  | 78 ++++++++++++++++---\n .../net/virtio/virtio_user/virtio_user_dev.h  |  2 +\n drivers/net/virtio/virtio_user_ethdev.c       |  7 +-\n 3 files changed, 74 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 8757a23f6e..61517692b3 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -259,20 +259,76 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)\n \treturn -1;\n }\n \n-static inline void\n-parse_mac(struct virtio_user_dev *dev, const char *mac)\n+int\n+virtio_user_dev_set_mac(struct virtio_user_dev *dev)\n {\n-\tstruct rte_ether_addr tmp;\n+\tint ret = 0;\n \n-\tif (!mac)\n-\t\treturn;\n+\tif (!(dev->device_features & (1ULL << VIRTIO_NET_F_MAC)))\n+\t\treturn -ENOTSUP;\n+\n+\tif (!dev->ops->set_config)\n+\t\treturn -ENOTSUP;\n+\n+\tret = dev->ops->set_config(dev, dev->mac_addr,\n+\t\t\toffsetof(struct virtio_net_config, mac),\n+\t\t\tRTE_ETHER_ADDR_LEN);\n+\tif (ret)\n+\t\tPMD_DRV_LOG(ERR, \"(%s) Failed to set MAC address in device\\n\", dev->path);\n+\n+\treturn ret;\n+}\n+\n+int\n+virtio_user_dev_get_mac(struct virtio_user_dev *dev)\n+{\n+\tint ret = 0;\n+\n+\tif (!(dev->device_features & (1ULL << VIRTIO_NET_F_MAC)))\n+\t\treturn -ENOTSUP;\n+\n+\tif (!dev->ops->get_config)\n+\t\treturn -ENOTSUP;\n+\n+\tret = dev->ops->get_config(dev, dev->mac_addr,\n+\t\t\toffsetof(struct virtio_net_config, mac),\n+\t\t\tRTE_ETHER_ADDR_LEN);\n+\tif (ret)\n+\t\tPMD_DRV_LOG(ERR, \"(%s) Failed to get MAC address from device\\n\", dev->path);\n \n-\tif (rte_ether_unformat_addr(mac, &tmp) == 0) {\n-\t\tmemcpy(dev->mac_addr, &tmp, RTE_ETHER_ADDR_LEN);\n+\treturn ret;\n+}\n+\n+static void\n+virtio_user_dev_init_mac(struct virtio_user_dev *dev, const char *mac)\n+{\n+\tstruct rte_ether_addr cmdline_mac;\n+\tint ret;\n+\n+\tif (mac && rte_ether_unformat_addr(mac, &cmdline_mac) == 0) {\n+\t\t/*\n+\t\t * MAC address was passed from command-line, try to store\n+\t\t * it in the device if it supports it. Otherwise try to use\n+\t\t * the device one.\n+\t\t */\n+\t\tmemcpy(dev->mac_addr, &cmdline_mac, RTE_ETHER_ADDR_LEN);\n \t\tdev->mac_specified = 1;\n+\n+\t\t/* Setting MAC may fail, continue to get the device one in this case */\n+\t\tvirtio_user_dev_set_mac(dev);\n+\t\tret = virtio_user_dev_get_mac(dev);\n+\t\tif (ret == -ENOTSUP)\n+\t\t\treturn;\n+\n+\t\tif (memcmp(&cmdline_mac, dev->mac_addr, RTE_ETHER_ADDR_LEN))\n+\t\t\tPMD_DRV_LOG(INFO, \"(%s) Device MAC update failed\\n\", dev->path);\n \t} else {\n-\t\t/* ignore the wrong mac, use random mac */\n-\t\tPMD_DRV_LOG(ERR, \"wrong format of mac: %s\", mac);\n+\t\tret = virtio_user_dev_get_mac(dev);\n+\t\tif (ret)\n+\t\t\tPMD_DRV_LOG(ERR, \"(%s) No valid MAC in devargs or device, use random\\n\",\n+\t\t\t\t\tdev->path);\n+\t\telse\n+\t\t\tdev->mac_specified = 1;\n \t}\n }\n \n@@ -508,8 +564,6 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \tdev->unsupported_features = 0;\n \tdev->backend_type = backend_type;\n \n-\tparse_mac(dev, mac);\n-\n \tif (*ifname) {\n \t\tdev->ifname = *ifname;\n \t\t*ifname = NULL;\n@@ -537,6 +591,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \t\treturn -1;\n \t}\n \n+\tvirtio_user_dev_init_mac(dev, mac);\n+\n \tif (!mrg_rxbuf)\n \t\tdev->unsupported_features |= (1ull << VIRTIO_NET_F_MRG_RXBUF);\n \ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex 8a62f7ea79..03bcf95970 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -78,6 +78,8 @@ uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);\n int virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status);\n int virtio_user_dev_update_status(struct virtio_user_dev *dev);\n int virtio_user_dev_update_link_state(struct virtio_user_dev *dev);\n+int virtio_user_dev_set_mac(struct virtio_user_dev *dev);\n+int virtio_user_dev_get_mac(struct virtio_user_dev *dev);\n void virtio_user_dev_delayed_handler(void *param);\n int virtio_user_dev_server_reconnect(struct virtio_user_dev *dev);\n extern const char * const virtio_user_backend_strings[];\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex bb36316186..34c8e7a9b5 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -60,12 +60,15 @@ virtio_user_write_dev_config(struct virtio_hw *hw, size_t offset,\n \tstruct virtio_user_dev *dev = virtio_user_get_dev(hw);\n \n \tif ((offset == offsetof(struct virtio_net_config, mac)) &&\n-\t    (length == RTE_ETHER_ADDR_LEN))\n+\t    (length == RTE_ETHER_ADDR_LEN)) {\n \t\tfor (i = 0; i < RTE_ETHER_ADDR_LEN; ++i)\n \t\t\tdev->mac_addr[i] = ((const uint8_t *)src)[i];\n-\telse\n+\t\tvirtio_user_dev_set_mac(dev);\n+\t\tvirtio_user_dev_get_mac(dev);\n+\t} else {\n \t\tPMD_DRV_LOG(ERR, \"not supported offset=%zu, len=%d\",\n \t\t\t    offset, length);\n+\t}\n }\n \n static void\n",
    "prefixes": [
        "RFC",
        "3/3"
    ]
}