Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/135769/?format=api
http://patches.dpdk.org/api/patches/135769/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240105222909.139674-5-stephen@networkplumber.org/", "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": "<20240105222909.139674-5-stephen@networkplumber.org>", "list_archive_url": "https://inbox.dpdk.org/dev/20240105222909.139674-5-stephen@networkplumber.org", "date": "2024-01-05T22:28:10", "name": "[RFC,4/5] tap: get errors from kernel on bpf load failure", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e5414a73d2a0cc0666aa2e6e35699bd959a4bd6b", "submitter": { "id": 27, "url": "http://patches.dpdk.org/api/people/27/?format=api", "name": "Stephen Hemminger", "email": "stephen@networkplumber.org" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240105222909.139674-5-stephen@networkplumber.org/mbox/", "series": [ { "id": 30745, "url": "http://patches.dpdk.org/api/series/30745/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30745", "date": "2024-01-05T22:28:06", "name": "BPF infrastructure enhancements", "version": 1, "mbox": "http://patches.dpdk.org/series/30745/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/135769/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/135769/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 D0DCB432AF;\n\tFri, 5 Jan 2024 23:29:43 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1CF6D406A2;\n\tFri, 5 Jan 2024 23:29:26 +0100 (CET)", "from mail-pl1-f182.google.com (mail-pl1-f182.google.com\n [209.85.214.182])\n by mails.dpdk.org (Postfix) with ESMTP id 060CE4064A\n for <dev@dpdk.org>; Fri, 5 Jan 2024 23:29:23 +0100 (CET)", "by mail-pl1-f182.google.com with SMTP id\n d9443c01a7336-1d4df66529bso196665ad.1\n for <dev@dpdk.org>; Fri, 05 Jan 2024 14:29:22 -0800 (PST)", "from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141])\n by smtp.gmail.com with ESMTPSA id\n b11-20020a170902d50b00b001d3e2578e66sm1871132plg.243.2024.01.05.14.29.21\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 05 Jan 2024 14:29:21 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704493762;\n x=1705098562; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=EMC2hvIAOiy3/mrk7PXiBIowfoclk5LfwLADKkfaubM=;\n b=xSdXrcqySL70MbbWtL02lQM8UGn37w1kLasTpR15Z34bFma3EbjBZMn015m/CoUU+y\n qBUXzE6C8HUWWXIyRvxq/wjWRTni+TjOEieVuaCqnjG1ryl6FzMuY4CPfR5wZ4p8ONkM\n fJKFk2cTUWGPaiekn9uqs1fX7RD9pb80oT9Q2PyxNkws3tI/iZWwYyp+RvmVURO91j7C\n GP9gcU3Q5q5dbpq1jbeRe5gDJSKWBcOJ3EOh6ei59GgBrB85uECY+yQhThkpwHfVkbRl\n JVtIMS/AvxrMF0C2A5WREpmHtktZLpmdliOZvOqO7GSn8w3Ixqx4PGOkvyQJHe2dGMzQ\n U7CA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1704493762; x=1705098562;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=EMC2hvIAOiy3/mrk7PXiBIowfoclk5LfwLADKkfaubM=;\n b=NzXmHlSYB3ptFuikazhN3PnJ8XkA1ldR3F3RxFOcTiGInK2puGyFkr1h4VhrVPgK2X\n tTV77GxTlyvW720zHuXXYs+fU9aVJG9M7LBPFLWlJlLucP3KDRBuejkdtOPMzEj7Pcfz\n 44xrtcF9UDa52wXS4OmHGYRY8MCtGmrbjNEeCSyVpIREnxQQZl4Yf0hoDQ1dWuQo/EIp\n iQSSiN7+s3hvSTbO1otO9aOHhbeOdfdiDTMwJZZBIhBJK9crdrFIRAo7LbGx+yHLPi/2\n HCZt3wJj2i0N/zZ9uVjl39n9zDLIpOhL1FLbPMxQfer8WECAJvNsieWm+NtF/HBSFl8B\n W7xg==", "X-Gm-Message-State": "AOJu0YxDsKGhEQB6tw5nzBlGiHv0Hek6VRL+0O8q1z6ZmraHSerTZ3Mh\n KnMXYxVHp0eBfgDv7AZ5fLyECQcd7yFM7ds1pjuDrV+8OjM=", "X-Google-Smtp-Source": "\n AGHT+IG7lUd8g9WYRqyFP6YPA5kUq/bBj7FoSj3acBGyOAD9LKBPyAou5zhcpWKDID6kEgOz0CEmvA==", "X-Received": "by 2002:a17:903:40d0:b0:1d3:ef79:4a2e with SMTP id\n t16-20020a17090340d000b001d3ef794a2emr128219pld.87.1704493762276;\n Fri, 05 Jan 2024 14:29:22 -0800 (PST)", "From": "Stephen Hemminger <stephen@networkplumber.org>", "To": "dev@dpdk.org", "Cc": "Stephen Hemminger <stephen@networkplumber.org>", "Subject": "[RFC 4/5] tap: get errors from kernel on bpf load failure", "Date": "Fri, 5 Jan 2024 14:28:10 -0800", "Message-ID": "<20240105222909.139674-5-stephen@networkplumber.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240105222909.139674-1-stephen@networkplumber.org>", "References": "<20240105222909.139674-1-stephen@networkplumber.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "The bpf load kernel API can provide some useful diagnostics\non failure.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/tap/tap_bpf_api.c | 44 +++++++++++++++++++++++++++--------\n drivers/net/tap/tap_flow.c | 16 ++++++++-----\n drivers/net/tap/tap_flow.h | 4 ++--\n 3 files changed, 46 insertions(+), 18 deletions(-)", "diff": "diff --git a/drivers/net/tap/tap_bpf_api.c b/drivers/net/tap/tap_bpf_api.c\nindex c754c167a764..29223b7f0ea7 100644\n--- a/drivers/net/tap/tap_bpf_api.c\n+++ b/drivers/net/tap/tap_bpf_api.c\n@@ -15,8 +15,10 @@\n #include <tap_bpf.h>\n #include <tap_bpf_insns.h>\n \n-static int bpf_load(enum bpf_prog_type type, const struct bpf_insn *insns,\n-\t\t size_t insns_cnt, const char *license);\n+static int bpf_load(enum bpf_prog_type type,\n+\t\t const struct bpf_insn *insns, size_t insns_cnt,\n+\t\t char *log_buf, size_t log_size,\n+\t\t const char *license);\n \n /**\n * Load BPF program (section cls_q) into the kernel and return a bpf fd\n@@ -24,15 +26,22 @@ static int bpf_load(enum bpf_prog_type type, const struct bpf_insn *insns,\n * @param queue_idx\n * Queue index matching packet cb\n *\n+ * @param log_buf\n+ * Buffer to place resulting error message (optional)\n+ *\n+ * @param log_size\n+ * Size of log_buf\n+ *\n * @return\n * -1 if the BPF program couldn't be loaded. An fd (int) otherwise.\n */\n-int tap_flow_bpf_cls_q(__u32 queue_idx)\n+int tap_flow_bpf_cls_q(__u32 queue_idx, char *log_buf, size_t log_size)\n {\n \tcls_q_insns[1].imm = queue_idx;\n \n \treturn bpf_load(BPF_PROG_TYPE_SCHED_CLS,\n \t\t\tcls_q_insns, RTE_DIM(cls_q_insns),\n+\t\t\tlog_buf, log_size,\n \t\t\t\"Dual BSD/GPL\");\n }\n \n@@ -45,16 +54,23 @@ int tap_flow_bpf_cls_q(__u32 queue_idx)\n * @param[in] map_fd\n * BPF RSS map file descriptor\n *\n+ * @param log_buf\n+ * Buffer to place resulting error message (optional)\n+ *\n+ * @param log_size\n+ * Size of log_buf\n+ *\n * @return\n * -1 if the BPF program couldn't be loaded. An fd (int) otherwise.\n */\n-int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd)\n+int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd, char *log_buf, size_t log_size)\n {\n \tl3_l4_hash_insns[4].imm = key_idx;\n \tl3_l4_hash_insns[9].imm = map_fd;\n \n \treturn bpf_load(BPF_PROG_TYPE_SCHED_ACT,\n \t\t\tl3_l4_hash_insns, RTE_DIM(l3_l4_hash_insns),\n+\t\t\tlog_buf, log_size,\n \t\t\t\"Dual BSD/GPL\");\n }\n \n@@ -105,6 +121,12 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,\n * @param[in] insns_cnt\n * Number of BPF instructions (size of array)\n *\n+ * @param[out] log_buf\n+ * Space for log message\n+ *\n+ * @param[in] log_size\n+ * Number of characters available in log_buf\n+ *\n * @param[in] license\n * License string that must be acknowledged by the kernel\n *\n@@ -112,9 +134,8 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,\n * -1 if the BPF program couldn't be loaded, fd (file descriptor) otherwise\n */\n static int bpf_load(enum bpf_prog_type type,\n-\t\t const struct bpf_insn *insns,\n-\t\t size_t insns_cnt,\n-\t\t const char *license)\n+\t\t const struct bpf_insn *insns, size_t insns_cnt,\n+\t\t char *log_buf, size_t log_size, const char *license)\n {\n \tunion bpf_attr attr = {};\n \n@@ -122,9 +143,12 @@ static int bpf_load(enum bpf_prog_type type,\n \tattr.insn_cnt = (__u32)insns_cnt;\n \tattr.insns = ptr_to_u64(insns);\n \tattr.license = ptr_to_u64(license);\n-\tattr.log_buf = ptr_to_u64(NULL);\n-\tattr.log_level = 0;\n-\tattr.kern_version = 0;\n+\n+\tif (log_size > 0) {\n+\t\tattr.log_level = 2;\n+\t\tattr.log_buf = ptr_to_u64(log_buf);\n+\t\tattr.log_size = log_size;\n+\t}\n \n \treturn sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr));\n }\ndiff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c\nindex ed4d42f92f9f..897d71acbad1 100644\n--- a/drivers/net/tap/tap_flow.c\n+++ b/drivers/net/tap/tap_flow.c\n@@ -18,6 +18,8 @@\n #include <tap_tcmsgs.h>\n #include <tap_rss.h>\n \n+#define BPF_LOG_BUFSIZ\t1024\n+\n #ifndef HAVE_TC_FLOWER\n /*\n * For kernels < 4.2, this enum is not defined. Runtime checks will be made to\n@@ -1885,11 +1887,13 @@ static int rss_enable(struct pmd_internals *pmd,\n \t * the correct queue.\n \t */\n \tfor (i = 0; i < pmd->dev->data->nb_rx_queues; i++) {\n-\t\tpmd->bpf_fd[i] = tap_flow_bpf_cls_q(i);\n+\t\tchar log_buf[BPF_LOG_BUFSIZ];\n+\n+\t\tpmd->bpf_fd[i] = tap_flow_bpf_cls_q(i, log_buf, sizeof(log_buf));\n \t\tif (pmd->bpf_fd[i] < 0) {\n \t\t\tTAP_LOG(ERR,\n-\t\t\t\t\"Failed to load BPF section %s for queue %d\",\n-\t\t\t\tSEC_NAME_CLS_Q, i);\n+\t\t\t\t\"Failed to load BPF section %s for queue %u: %s\",\n+\t\t\t\tSEC_NAME_CLS_Q, i, log_buf);\n \t\t\trte_flow_error_set(\n \t\t\t\terror, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,\n \t\t\t\tNULL,\n@@ -2074,6 +2078,7 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,\n \t/* 4096 is the maximum number of instructions for a BPF program */\n \tunsigned int i;\n \tint err;\n+\tchar log_buf[BPF_LOG_BUFSIZ];\n \tstruct rss_key rss_entry = { .hash_fields = 0,\n \t\t\t\t .key_size = 0 };\n \n@@ -2124,9 +2129,8 @@ static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,\n \t/*\n \t * Load bpf rules to calculate hash for this key_idx\n \t */\n-\n-\tflow->bpf_fd[SEC_L3_L4] =\n-\t\ttap_flow_bpf_calc_l3_l4_hash(flow->key_idx, pmd->map_fd);\n+\tflow->bpf_fd[SEC_L3_L4] = tap_flow_bpf_calc_l3_l4_hash(flow->key_idx, pmd->map_fd,\n+\t\t\t\t\t\t\t log_buf, sizeof(log_buf));\n \tif (flow->bpf_fd[SEC_L3_L4] < 0) {\n \t\tTAP_LOG(ERR,\n \t\t\t\"Failed to load BPF section %s (%d): %s\",\ndiff --git a/drivers/net/tap/tap_flow.h b/drivers/net/tap/tap_flow.h\nindex 240fbc3dfaef..fb30b495fda1 100644\n--- a/drivers/net/tap/tap_flow.h\n+++ b/drivers/net/tap/tap_flow.h\n@@ -57,8 +57,8 @@ int tap_flow_implicit_destroy(struct pmd_internals *pmd,\n int tap_flow_implicit_flush(struct pmd_internals *pmd,\n \t\t\t struct rte_flow_error *error);\n \n-int tap_flow_bpf_cls_q(__u32 queue_idx);\n-int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd);\n+int tap_flow_bpf_cls_q(__u32 queue_idx, char *log_buf, size_t log_size);\n+int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd, char *log_buf, size_t log_size);\n int tap_flow_bpf_rss_map_create(unsigned int key_size, unsigned int value_size,\n \t\t\tunsigned int max_entries);\n int tap_flow_bpf_update_rss_elem(int fd, void *key, void *value);\n", "prefixes": [ "RFC", "4/5" ] }{ "id": 135769, "url": "