get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 105239,
    "url": "http://patches.dpdk.org/api/patches/105239/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com",
    "date": "2021-12-18T02:51:28",
    "name": "[v1,01/25] drivers/net: introduce a new PMD driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0ed8c1c4b12be0468f49008eb9bdbc6562c1b457",
    "submitter": {
        "id": 2455,
        "url": "http://patches.dpdk.org/api/people/2455/?format=api",
        "name": "Yanling Song",
        "email": "songyl@ramaxel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com/mbox/",
    "series": [
        {
            "id": 20973,
            "url": "http://patches.dpdk.org/api/series/20973/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=20973",
            "date": "2021-12-18T02:51:28",
            "name": "Net/SPNIC: support SPNIC into DPDK 22.03",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/20973/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/105239/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/105239/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 3B946A04A4;\n\tSat, 18 Dec 2021 03:52:08 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id BD24E4013F;\n\tSat, 18 Dec 2021 03:52:07 +0100 (CET)",
            "from VLXDG1SPAM1.ramaxel.com (email.ramaxel.com [221.4.138.186])\n by mails.dpdk.org (Postfix) with ESMTP id 4AE3540040\n for <dev@dpdk.org>; Sat, 18 Dec 2021 03:52:04 +0100 (CET)",
            "from V12DG1MBS01.ramaxel.local (v12dg1mbs01.ramaxel.local\n [172.26.18.31])\n by VLXDG1SPAM1.ramaxel.com with ESMTPS id 1BI2pwxm010300\n (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);\n Sat, 18 Dec 2021 10:51:58 +0800 (GMT-8)\n (envelope-from songyl@ramaxel.com)",
            "from localhost.localdomain (10.64.9.47) by V12DG1MBS01.ramaxel.local\n (172.26.18.31) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Sat, 18\n Dec 2021 10:51:57 +0800"
        ],
        "From": "Yanling Song <songyl@ramaxel.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<songyl@ramaxel.com>, <yanling.song@linux.dev>, <yanggan@ramaxel.com>,\n <ferruh.yigit@intel.com>",
        "Subject": "[PATCH v1 01/25] drivers/net: introduce a new PMD driver",
        "Date": "Sat, 18 Dec 2021 10:51:28 +0800",
        "Message-ID": "\n <913359f582b165a3fcfe5efbd4dab76476690a53.1639636621.git.songyl@ramaxel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<cover.1639636621.git.songyl@ramaxel.com>",
        "References": "<cover.1639636621.git.songyl@ramaxel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Originating-IP": "[10.64.9.47]",
        "X-ClientProxiedBy": "V12DG1MBS01.ramaxel.local (172.26.18.31) To\n V12DG1MBS01.ramaxel.local (172.26.18.31)",
        "X-DNSRBL": "",
        "X-MAIL": "VLXDG1SPAM1.ramaxel.com 1BI2pwxm010300",
        "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"
    },
    "content": "Introduce a new PMD driver which names spnic.\nNow, this driver only implements module entry\nwithout doing anything else.\n\nSigned-off-by: Yanling Song <songyl@ramaxel.com>\n---\n drivers/net/meson.build               |   1 +\n drivers/net/spnic/base/meson.build    |  26 ++++\n drivers/net/spnic/base/spnic_compat.h | 188 ++++++++++++++++++++++++++\n drivers/net/spnic/meson.build         |  11 ++\n drivers/net/spnic/spnic_ethdev.c      | 107 +++++++++++++++\n drivers/net/spnic/spnic_ethdev.h      |  28 ++++\n drivers/net/spnic/version.map         |   3 +\n 7 files changed, 364 insertions(+)\n create mode 100644 drivers/net/spnic/base/meson.build\n create mode 100644 drivers/net/spnic/base/spnic_compat.h\n create mode 100644 drivers/net/spnic/meson.build\n create mode 100644 drivers/net/spnic/spnic_ethdev.c\n create mode 100644 drivers/net/spnic/spnic_ethdev.h\n create mode 100644 drivers/net/spnic/version.map",
    "diff": "diff --git a/drivers/net/meson.build b/drivers/net/meson.build\nindex 2355d1cde8..a5c715f59c 100644\n--- a/drivers/net/meson.build\n+++ b/drivers/net/meson.build\n@@ -53,6 +53,7 @@ drivers = [\n         'ring',\n         'sfc',\n         'softnic',\n+\t'spnic',\n         'tap',\n         'thunderx',\n         'txgbe',\ndiff --git a/drivers/net/spnic/base/meson.build b/drivers/net/spnic/base/meson.build\nnew file mode 100644\nindex 0000000000..e83a473881\n--- /dev/null\n+++ b/drivers/net/spnic/base/meson.build\n@@ -0,0 +1,26 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2021 Ramaxel Memory Technology, Ltd\n+\n+sources = [\n+]\n+\n+extra_flags = []\n+# The driver runs only on arch64 machine, remove 32bit warnings\n+if not dpdk_conf.get('RTE_ARCH_64')\n+        extra_flags += ['-Wno-int-to-pointer-cast', '-Wno-pointer-to-int-cast']\n+endif\n+\n+foreach flag: extra_flags\n+        if cc.has_argument(flag)\n+                cflags += flag\n+        endif\n+endforeach\n+\n+deps += ['hash']\n+cflags += ['-DHW_CONVERT_ENDIAN']\n+c_args = cflags\n+\n+base_lib = static_library('spnic_base', sources,\n+\tdependencies: [static_rte_eal, static_rte_ethdev, static_rte_bus_pci, static_rte_hash],\n+\tc_args: c_args)\n+base_objs = base_lib.extract_all_objects()\ndiff --git a/drivers/net/spnic/base/spnic_compat.h b/drivers/net/spnic/base/spnic_compat.h\nnew file mode 100644\nindex 0000000000..dd0ea2a04e\n--- /dev/null\n+++ b/drivers/net/spnic/base/spnic_compat.h\n@@ -0,0 +1,188 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021 Ramaxel Memory Technology, Ltd\n+ */\n+\n+#ifndef _SPNIC_COMPAT_H_\n+#define _SPNIC_COMPAT_H_\n+\n+#include <stdint.h>\n+#include <stdbool.h>\n+#include <sys/time.h>\n+#include <unistd.h>\n+#include <pthread.h>\n+#include <rte_common.h>\n+#include <rte_byteorder.h>\n+#include <rte_memzone.h>\n+#include <rte_memcpy.h>\n+#include <rte_malloc.h>\n+#include <rte_atomic.h>\n+#include <rte_spinlock.h>\n+#include <rte_cycles.h>\n+#include <rte_log.h>\n+#include <rte_config.h>\n+#include <rte_io.h>\n+\n+typedef uint8_t   u8;\n+typedef int8_t    s8;\n+typedef uint16_t  u16;\n+typedef uint32_t  u32;\n+typedef int32_t   s32;\n+typedef uint64_t  u64;\n+\n+#ifndef BIT\n+#define BIT(n) (1 << (n))\n+#endif\n+\n+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))\n+#define lower_32_bits(n) ((u32)(n))\n+\n+#define SPNIC_MEM_ALLOC_ALIGN_MIN\t1\n+\n+#define SPNIC_DRIVER_NAME \"spnic\"\n+\n+extern int spnic_logtype;\n+\n+#define PMD_DRV_LOG(level, fmt, args...) \\\n+\trte_log(RTE_LOG_ ## level, spnic_logtype, \\\n+\t\tSPNIC_DRIVER_NAME \": \" fmt \"\\n\", ##args)\n+\n+/* Bit order interface */\n+#define cpu_to_be16(o) rte_cpu_to_be_16(o)\n+#define cpu_to_be32(o) rte_cpu_to_be_32(o)\n+#define cpu_to_be64(o) rte_cpu_to_be_64(o)\n+#define cpu_to_le32(o) rte_cpu_to_le_32(o)\n+#define be16_to_cpu(o) rte_be_to_cpu_16(o)\n+#define be32_to_cpu(o) rte_be_to_cpu_32(o)\n+#define be64_to_cpu(o) rte_be_to_cpu_64(o)\n+#define le32_to_cpu(o) rte_le_to_cpu_32(o)\n+\n+#define ARRAY_LEN(arr) ((sizeof(arr) / sizeof((arr)[0])))\n+\n+#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */\n+#define CLOCK_TYPE CLOCK_MONOTONIC_RAW\n+#else\n+#define CLOCK_TYPE CLOCK_MONOTONIC\n+#endif\n+\n+#define SPNIC_MUTEX_TIMEOUT\t10\n+#define SPNIC_S_TO_MS_UNIT\t1000\n+#define SPNIC_S_TO_NS_UNIT\t1000000\n+\n+static inline unsigned long clock_gettime_ms(void)\n+{\n+\tstruct timespec tv;\n+\n+\t(void)clock_gettime(CLOCK_TYPE, &tv);\n+\n+\treturn (unsigned long)tv.tv_sec * SPNIC_S_TO_MS_UNIT +\n+\t       (unsigned long)tv.tv_nsec / SPNIC_S_TO_NS_UNIT;\n+}\n+\n+#define jiffies\tclock_gettime_ms()\n+#define msecs_to_jiffies(ms)\t(ms)\n+#define time_before(now, end)\t((now) < (end))\n+\n+/**\n+ * Convert data to big endian 32 bit format\n+ *\n+ * @param data\n+ *   The data to convert\n+ * @param len\n+ *   Length of data to convert, must be Multiple of 4B\n+ */\n+static inline void spnic_cpu_to_be32(void *data, int len)\n+{\n+\tint i, chunk_sz = sizeof(u32);\n+\tu32 *mem = data;\n+\n+\tif (!data)\n+\t\treturn;\n+\n+\tlen = len / chunk_sz;\n+\n+\tfor (i = 0; i < len; i++) {\n+\t\t*mem = cpu_to_be32(*mem);\n+\t\tmem++;\n+\t}\n+}\n+\n+/**\n+ * Convert data from big endian 32 bit format\n+ *\n+ * @param data\n+ *   The data to convert\n+ * @param len\n+ *   Length of data to convert, must be Multiple of 4B\n+ */\n+static inline void spnic_be32_to_cpu(void *data, int len)\n+{\n+\tint i, chunk_sz = sizeof(u32);\n+\tu32 *mem = data;\n+\n+\tif (!data)\n+\t\treturn;\n+\n+\tlen = len / chunk_sz;\n+\n+\tfor (i = 0; i < len; i++) {\n+\t\t*mem = be32_to_cpu(*mem);\n+\t\tmem++;\n+\t}\n+}\n+\n+static inline u16 ilog2(u32 n)\n+{\n+\tu16 res = 0;\n+\n+\twhile (n > 1) {\n+\t\tn >>= 1;\n+\t\tres++;\n+\t}\n+\n+\treturn res;\n+}\n+\n+static inline int spnic_mutex_init(pthread_mutex_t *pthreadmutex,\n+\t\t\t\t   const pthread_mutexattr_t *mattr)\n+{\n+\tint err;\n+\n+\terr = pthread_mutex_init(pthreadmutex, mattr);\n+\tif (unlikely(err))\n+\t\tPMD_DRV_LOG(ERR, \"Initialize mutex failed, error: %d\", err);\n+\n+\treturn err;\n+}\n+\n+static inline int spnic_mutex_destroy(pthread_mutex_t *pthreadmutex)\n+{\n+\tint err;\n+\n+\terr = pthread_mutex_destroy(pthreadmutex);\n+\tif (unlikely(err))\n+\t\tPMD_DRV_LOG(ERR, \"Destroy mutex failed, error: %d\", err);\n+\n+\treturn err;\n+}\n+\n+static inline int spnic_mutex_lock(pthread_mutex_t *pthreadmutex)\n+{\n+\tstruct timespec tout;\n+\tint err;\n+\n+\t(void)clock_gettime(CLOCK_TYPE, &tout);\n+\n+\ttout.tv_sec += SPNIC_MUTEX_TIMEOUT;\n+\terr = pthread_mutex_timedlock(pthreadmutex, &tout);\n+\tif (err)\n+\t\tPMD_DRV_LOG(ERR, \"Mutex lock failed, err: %d\", err);\n+\n+\treturn err;\n+}\n+\n+static inline int spnic_mutex_unlock(pthread_mutex_t *pthreadmutex)\n+{\n+\treturn pthread_mutex_unlock(pthreadmutex);\n+}\n+\n+#endif /* _SPNIC_COMPAT_H_ */\ndiff --git a/drivers/net/spnic/meson.build b/drivers/net/spnic/meson.build\nnew file mode 100644\nindex 0000000000..042d2fe6e1\n--- /dev/null\n+++ b/drivers/net/spnic/meson.build\n@@ -0,0 +1,11 @@\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2021 Ramaxel Memory Technology, Ltd\n+\n+subdir('base')\n+objs = [base_objs]\n+\n+sources = files(\n+\t'spnic_ethdev.c',\n+\t)\n+\n+includes += include_directories('base')\ndiff --git a/drivers/net/spnic/spnic_ethdev.c b/drivers/net/spnic/spnic_ethdev.c\nnew file mode 100644\nindex 0000000000..b06492a8e9\n--- /dev/null\n+++ b/drivers/net/spnic/spnic_ethdev.c\n@@ -0,0 +1,107 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021 Ramaxel Memory Technology, Ltd\n+ */\n+\n+#include <rte_pci.h>\n+#include <rte_bus_pci.h>\n+#include <ethdev_pci.h>\n+#include <rte_errno.h>\n+#include <rte_ether.h>\n+\n+#include \"base/spnic_compat.h\"\n+#include \"spnic_ethdev.h\"\n+\n+/* Driver-specific log messages type */\n+int spnic_logtype;\n+\n+static int spnic_func_init(struct rte_eth_dev *eth_dev)\n+{\n+\tstruct spnic_nic_dev *nic_dev = NULL;\n+\tstruct rte_pci_device *pci_dev = NULL;\n+\n+\tpci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n+\n+\t/* EAL is secondary and eth_dev is already created */\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY) {\n+\t\tPMD_DRV_LOG(INFO, \"Initialize %s in secondary process\",\n+\t\t\t    eth_dev->data->name);\n+\n+\t\treturn 0;\n+\t}\n+\n+\tnic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);\n+\tsnprintf(nic_dev->dev_name, sizeof(nic_dev->dev_name),\n+\t\t \"spnic-%.4x:%.2x:%.2x.%x\",\n+\t\t pci_dev->addr.domain, pci_dev->addr.bus,\n+\t\t pci_dev->addr.devid, pci_dev->addr.function);\n+\n+\trte_bit_relaxed_set32(SPNIC_DEV_INIT, &nic_dev->dev_status);\n+\tPMD_DRV_LOG(INFO, \"Initialize %s in primary succeed\",\n+\t\t    eth_dev->data->name);\n+\n+\treturn 0;\n+}\n+\n+static int spnic_dev_init(struct rte_eth_dev *eth_dev)\n+{\n+\tstruct rte_pci_device *pci_dev;\n+\n+\tpci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n+\n+\tPMD_DRV_LOG(INFO, \"Initializing spnic-%.4x:%.2x:%.2x.%x in %s process\",\n+\t\t    pci_dev->addr.domain, pci_dev->addr.bus,\n+\t\t    pci_dev->addr.devid, pci_dev->addr.function,\n+\t\t    (rte_eal_process_type() == RTE_PROC_PRIMARY) ?\n+\t\t    \"primary\" : \"secondary\");\n+\n+\treturn spnic_func_init(eth_dev);\n+}\n+\n+static int spnic_dev_uninit(struct rte_eth_dev *dev)\n+{\n+\tstruct spnic_nic_dev *nic_dev;\n+\n+\tnic_dev = SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);\n+\trte_bit_relaxed_clear32(SPNIC_DEV_INIT, &nic_dev->dev_status);\n+\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn 0;\n+\n+\treturn 0;\n+}\n+\n+static struct rte_pci_id pci_id_spnic_map[] = {\n+\t{ RTE_PCI_DEVICE(PCI_VENDOR_ID_RAMAXEL, SPNIC_DEV_ID_PF) },\n+\t{ RTE_PCI_DEVICE(PCI_VENDOR_ID_RAMAXEL, SPNIC_DEV_ID_VF) },\n+\t{.vendor_id = 0},\n+};\n+\n+static int spnic_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,\n+\t\t\t   struct rte_pci_device *pci_dev)\n+{\n+\treturn rte_eth_dev_pci_generic_probe(pci_dev,\n+\t\t\t\t\t     sizeof(struct spnic_nic_dev),\n+\t\t\t\t\t     spnic_dev_init);\n+}\n+\n+static int spnic_pci_remove(struct rte_pci_device *pci_dev)\n+{\n+\treturn rte_eth_dev_pci_generic_remove(pci_dev, spnic_dev_uninit);\n+}\n+\n+static struct rte_pci_driver rte_spnic_pmd = {\n+\t.id_table = pci_id_spnic_map,\n+\t.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,\n+\t.probe = spnic_pci_probe,\n+\t.remove = spnic_pci_remove,\n+};\n+\n+RTE_PMD_REGISTER_PCI(net_spnic, rte_spnic_pmd);\n+RTE_PMD_REGISTER_PCI_TABLE(net_spnic, pci_id_spnic_map);\n+\n+RTE_INIT(spnic_init_log)\n+{\n+\tspnic_logtype = rte_log_register(\"pmd.net.spnic\");\n+\tif (spnic_logtype >= 0)\n+\t\trte_log_set_level(spnic_logtype, RTE_LOG_INFO);\n+}\ndiff --git a/drivers/net/spnic/spnic_ethdev.h b/drivers/net/spnic/spnic_ethdev.h\nnew file mode 100644\nindex 0000000000..d4ec641d83\n--- /dev/null\n+++ b/drivers/net/spnic/spnic_ethdev.h\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2021 Ramaxel Memory Technology, Ltd\n+ */\n+\n+#ifndef _SPNIC_ETHDEV_H_\n+#define _SPNIC_ETHDEV_H_\n+\n+/* Vendor id */\n+#define PCI_VENDOR_ID_RAMAXEL\t0x1E81\n+\n+/* Device ids */\n+#define SPNIC_DEV_ID_PF\t\t\t0x9020\n+#define SPNIC_DEV_ID_VF\t\t\t0x9001\n+\n+enum spnic_dev_status {\n+\tSPNIC_DEV_INIT\n+};\n+\n+#define SPNIC_DEV_NAME_LEN\t\t32\n+struct spnic_nic_dev {\n+\tu32 dev_status;\n+\tchar dev_name[SPNIC_DEV_NAME_LEN];\n+};\n+\n+#define SPNIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev) \\\n+\t((struct spnic_nic_dev *)(dev)->data->dev_private)\n+\n+#endif /* _SPNIC_ETHDEV_H_ */\ndiff --git a/drivers/net/spnic/version.map b/drivers/net/spnic/version.map\nnew file mode 100644\nindex 0000000000..4a76d1d52d\n--- /dev/null\n+++ b/drivers/net/spnic/version.map\n@@ -0,0 +1,3 @@\n+DPDK_21 {\n+\tlocal: *;\n+};\n",
    "prefixes": [
        "v1",
        "01/25"
    ]
}