From: Weihang Li <liweihang@hisilicon.com>
To: <dledford@redhat.com>, <jgg@ziepe.ca>
Cc: <linux-rdma@vger.kernel.org>, <linuxarm@huawei.com>
Subject: [PATCH rdma-core 5/5] libhns: Support configuring loopback mode by user
Date: Tue, 10 Sep 2019 20:20:52 +0800 [thread overview]
Message-ID: <1568118052-33380-6-git-send-email-liweihang@hisilicon.com> (raw)
In-Reply-To: <1568118052-33380-1-git-send-email-liweihang@hisilicon.com>
User can configure whether hardware working on loopback mode or not
by export an environment variable "HNS_ROCE_LOOPBACK".
Signed-off-by: Weihang Li <liweihang@hisilicon.com>
---
providers/hns/hns_roce_u.c | 15 +++++++++++++++
providers/hns/hns_roce_u.h | 2 ++
providers/hns/hns_roce_u_hw_v2.c | 3 ++-
providers/hns/hns_roce_u_verbs.c | 1 +
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 8ba41de..f68c84b 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -40,6 +40,8 @@
#include "hns_roce_u.h"
#include "hns_roce_u_abi.h"
+bool loopback;
+
#define HID_LEN 15
#define DEV_MATCH_LEN 128
@@ -85,6 +87,17 @@ static const struct verbs_context_ops hns_common_ops = {
.destroy_ah = hns_roce_u_destroy_ah,
};
+static bool get_param_config(const char *var)
+{
+ char *env;
+
+ env = getenv(var);
+ if (env)
+ return strcmp(env, "true") ? true : false;
+
+ return false;
+}
+
static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
int cmd_fd,
void *private_data)
@@ -105,6 +118,8 @@ static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
&resp.ibv_resp, sizeof(resp)))
goto err_free;
+ loopback = get_param_config("HNS_ROCE_LOOPBACK");
+
context->num_qps = resp.qp_tab_size;
context->qp_table_shift = ffs(context->num_qps) - 1 -
HNS_ROCE_QP_TABLE_BITS;
diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h
index 9d8f72e..624bdaa 100644
--- a/providers/hns/hns_roce_u.h
+++ b/providers/hns/hns_roce_u.h
@@ -43,6 +43,7 @@
#include <ccan/bitmap.h>
#include <ccan/container_of.h>
+extern bool loopback;
#define HNS_ROCE_HW_VER1 ('h' << 24 | 'i' << 16 | '0' << 8 | '6')
#define HNS_ROCE_HW_VER2 ('h' << 24 | 'i' << 16 | '0' << 8 | '8')
@@ -265,6 +266,7 @@ struct hns_roce_av {
uint8_t mac[ETH_ALEN];
uint16_t vlan_id;
uint8_t vlan_en;
+ uint8_t loopback;
};
struct hns_roce_ah {
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index dd7545f..62e8561 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -685,7 +685,8 @@ static void set_ud_wqe(void *wqe, struct hns_roce_qp *qp,
roce_set_bit(ud_sq_wqe->lbi_flow_label, UD_SQ_WQE_VLAN_EN_S,
ah->av.vlan_en ? 1 : 0);
- roce_set_bit(ud_sq_wqe->lbi_flow_label, UD_SQ_WQE_LBI_S, 0);
+ roce_set_bit(ud_sq_wqe->lbi_flow_label, UD_SQ_WQE_LBI_S,
+ ah->av.loopback);
roce_set_field(ud_sq_wqe->lbi_flow_label, UD_SQ_WQE_SL_M,
UD_SQ_WQE_SL_S, ah->av.sl);
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 5255fff..ff24ae3 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -970,6 +970,7 @@ struct ibv_ah *hns_roce_u_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
ah->av.port = attr->port_num;
ah->av.sl = attr->sl;
+ ah->av.loopback = loopback ? 1 : 0;
if (attr->static_rate)
ah->av.static_rate = IBV_RATE_10_GBPS;
--
2.8.1
next prev parent reply other threads:[~2019-09-10 12:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 12:20 [PATCH rdma-core 0/5] Support UD on hip08 Weihang Li
2019-09-10 12:20 ` [PATCH rdma-core 1/5] libhns: Add support of handling AH for hip08 Weihang Li
2019-09-10 12:20 ` [PATCH rdma-core 2/5] libhns: Bugfix for wqe idx calc of post verbs Weihang Li
2019-09-10 12:20 ` [PATCH rdma-core 3/5] libhns: Refactor for post send Weihang Li
2019-09-11 7:35 ` Leon Romanovsky
2019-09-11 7:50 ` liweihang
2019-09-10 12:20 ` [PATCH rdma-core 4/5] libhns: Add UD support for hip08 in user mode Weihang Li
2019-09-10 12:20 ` Weihang Li [this message]
2019-09-11 7:42 ` [PATCH rdma-core 5/5] libhns: Support configuring loopback mode by user Leon Romanovsky
2019-09-11 12:40 ` liweihang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1568118052-33380-6-git-send-email-liweihang@hisilicon.com \
--to=liweihang@hisilicon.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).