From 12f8951a6a98f82dd1f70afc23d66e328cf1988b Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
Date: Thu, 7 Dec 2023 09:47:59 +0800
Subject: [PATCH] libhns: Fix parent domain unsupported comp mask

driver inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8MF28

Hns do not support any comp mask for parent domain. Driver returns
EINVAL if any compmask is set.

This patch Replace the inappropriate return value EINVAL with
EOPNOTSUPP.

The error is found by testcase test_mem_align_ud_traffic.

ERROR: test_mem_align_ud_traffic (tests.test_parent_domain.ParentDomain
TrafficTest)

----------------------------------------------------------------------

Traceback (most recent call last):
  File "./tests/test_parent_domain.py", line 183, in test_mem_align_ud
_traffic
    self.create_players(parent_domain_ud_res,
  File "./tests/test_parent_domain.py", line 156, in create_players
    self.client = resource(**self.dev_info, **resource_arg)
  File "./tests/test_parent_domain.py", line 90, in __init__
    super().__init__(**kwargs)
  File "./tests/base.py", line 617, in __init__
    super(RoCETrafficResources, self).__init__(dev_name, ib_port,
gid_index, **kwargs)
  File "./tests/base.py", line 503, in __init__
    super(TrafficResources, self).__init__(dev_name=dev_name,
  File "./tests/base.py", line 477, in __init__
    self.create_pd()
  File "./tests/test_parent_domain.py", line 95, in create_pd
    create_parent_domain_with_allocators(self)
  File "./tests/test_parent_domain.py", line 69, in create_parent_
domain_with_allocators
    raise ex
  File "./tests/test_parent_domain.py", line 65, in create_parent_
domain_with_allocators
    res.pd = ParentDomain(res.ctx, attr=pd_attr)
  File "pd.pyx", line 261, in pyverbs.pd.ParentDomain.__init__
pyverbs.pyverbs_error.PyverbsRDMAError: Failed to allocate Parent
Domain.Errno: 22, Invalid argument

Fixes: cfe548d4c78e ("libhns: Add support for the thread
domain and the parent domain")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
 providers/hns/hns_roce_u_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 34e8d07..ba3fef6 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -238,7 +238,7 @@ struct ibv_pd *hns_roce_u_alloc_pad(struct ibv_context *context,
 		return NULL;
 
 	if (attr->comp_mask) {
-		errno = EINVAL;
+		errno = EOPNOTSUPP;
 		return NULL;
 	}
 
-- 
2.25.1

