common/cnxk: support TM error type get
authorSatha Rao <skoteshwar@marvell.com>
Wed, 22 Sep 2021 06:11:45 +0000 (02:11 -0400)
committerJerin Jacob <jerinj@marvell.com>
Tue, 28 Sep 2021 10:06:39 +0000 (12:06 +0200)
Different TM handlers returns various platform specific errors,
this patch introduces new API to convert these internal error
types to RTE_TM* error types.
Also updated error message API with missed TM error types.

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
drivers/common/cnxk/cnxk_utils.c [new file with mode: 0644]
drivers/common/cnxk/cnxk_utils.h [new file with mode: 0644]
drivers/common/cnxk/meson.build
drivers/common/cnxk/roc_utils.c
drivers/common/cnxk/version.map

diff --git a/drivers/common/cnxk/cnxk_utils.c b/drivers/common/cnxk/cnxk_utils.c
new file mode 100644 (file)
index 0000000..4e56adc
--- /dev/null
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+#include <rte_log.h>
+#include <rte_tm_driver.h>
+
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include "cnxk_utils.h"
+
+int
+roc_nix_tm_err_to_rte_err(int errorcode)
+{
+       int err_type;
+
+       switch (errorcode) {
+       case NIX_ERR_TM_SHAPER_PKT_LEN_ADJUST:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN;
+               break;
+       case NIX_ERR_TM_INVALID_COMMIT_SZ:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;
+               break;
+       case NIX_ERR_TM_INVALID_COMMIT_RATE:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;
+               break;
+       case NIX_ERR_TM_INVALID_PEAK_SZ:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;
+               break;
+       case NIX_ERR_TM_INVALID_PEAK_RATE:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE;
+               break;
+       case NIX_ERR_TM_INVALID_SHAPER_PROFILE:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
+               break;
+       case NIX_ERR_TM_SHAPER_PROFILE_IN_USE:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
+               break;
+       case NIX_ERR_TM_INVALID_NODE:
+               err_type = RTE_TM_ERROR_TYPE_NODE_ID;
+               break;
+       case NIX_ERR_TM_PKT_MODE_MISMATCH:
+               err_type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
+               break;
+       case NIX_ERR_TM_INVALID_PARENT:
+       case NIX_ERR_TM_PARENT_PRIO_UPDATE:
+               err_type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
+               break;
+       case NIX_ERR_TM_PRIO_ORDER:
+       case NIX_ERR_TM_MULTIPLE_RR_GROUPS:
+               err_type = RTE_TM_ERROR_TYPE_NODE_PRIORITY;
+               break;
+       case NIX_ERR_TM_PRIO_EXCEEDED:
+               err_type = RTE_TM_ERROR_TYPE_CAPABILITIES;
+               break;
+       default:
+               /**
+                * Handle general error (as defined in linux errno.h)
+                */
+               if (abs(errorcode) < 300)
+                       err_type = errorcode;
+               else
+                       err_type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
+               break;
+       }
+
+       return err_type;
+}
diff --git a/drivers/common/cnxk/cnxk_utils.h b/drivers/common/cnxk/cnxk_utils.h
new file mode 100644 (file)
index 0000000..5463cd4
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+#ifndef _CNXK_UTILS_H_
+#define _CNXK_UTILS_H_
+
+#include "roc_platform.h"
+
+int __roc_api roc_nix_tm_err_to_rte_err(int errorcode);
+
+#endif /* _CNXK_UTILS_H_ */
index 8a551d1..258429d 100644 (file)
@@ -61,5 +61,10 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
+# common DPDK utilities code
+sources += files('cnxk_utils.c')
+
 includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
+includes += include_directories('../../../lib/ethdev')
+includes += include_directories('../../../lib/meter')
index 9cb8708..751486f 100644 (file)
@@ -64,6 +64,9 @@ roc_error_msg_get(int errorcode)
        case NIX_ERR_TM_INVALID_SHAPER_PROFILE:
                err_msg = "TM shaper profile invalid";
                break;
+       case NIX_ERR_TM_PKT_MODE_MISMATCH:
+               err_msg = "shaper profile pkt mode mismatch";
+               break;
        case NIX_ERR_TM_WEIGHT_EXCEED:
                err_msg = "TM DWRR weight exceeded";
                break;
@@ -88,6 +91,9 @@ roc_error_msg_get(int errorcode)
        case NIX_ERR_TM_SHAPER_PROFILE_EXISTS:
                err_msg = "TM shaper profile exists";
                break;
+       case NIX_ERR_TM_SHAPER_PKT_LEN_ADJUST:
+               err_msg = "length adjust invalid";
+               break;
        case NIX_ERR_TM_INVALID_TREE:
                err_msg = "TM tree invalid";
                break;
index 388f938..776cabb 100644 (file)
@@ -172,6 +172,7 @@ INTERNAL {
        roc_nix_eeprom_info_get;
        roc_nix_smq_flush;
        roc_nix_tm_dump;
+       roc_nix_tm_err_to_rte_err;
        roc_nix_tm_fini;
        roc_nix_tm_free_resources;
        roc_nix_tm_hierarchy_disable;