From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AAE1645C76; Mon, 4 Nov 2024 12:17:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D055240E3A; Mon, 4 Nov 2024 12:12:45 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 5935140E2C for ; Mon, 4 Nov 2024 12:10:44 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Xhpcv3c0qz1SDxp; Mon, 4 Nov 2024 19:09:03 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id 8E6691400D2; Mon, 4 Nov 2024 19:10:42 +0800 (CST) Received: from localhost.huawei.com (10.50.165.33) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 4 Nov 2024 19:10:41 +0800 From: Dengdui Huang To: CC: , , , , , , , , , , Subject: [PATCH v5 23/52] net/bnxt: replace strerror with reentrant version Date: Mon, 4 Nov 2024 19:10:08 +0800 Message-ID: <20241104111037.3632161-24-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241104111037.3632161-1-huangdengdui@huawei.com> References: <20231114082539.1858594-1-huangdengdui@huawei.com> <20241104111037.3632161-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500011.china.huawei.com (7.185.36.84) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The function strerror() is insecure in a multi-thread environment. This patch uses strerror_r() to replace it. Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng Acked-by: Morten Brørup Acked-by: Huisong Li Acked-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_stats.c | 8 +- drivers/net/bnxt/rte_pmd_bnxt.c | 65 ++- drivers/net/bnxt/tf_core/tf_core.c | 509 +++++++++++++----- drivers/net/bnxt/tf_core/tf_em_common.c | 56 +- .../net/bnxt/tf_core/tf_em_hash_internal.c | 10 +- drivers/net/bnxt/tf_core/tf_em_host.c | 51 +- drivers/net/bnxt/tf_core/tf_em_internal.c | 32 +- drivers/net/bnxt/tf_core/tf_global_cfg.c | 23 +- drivers/net/bnxt/tf_core/tf_identifier.c | 20 +- drivers/net/bnxt/tf_core/tf_if_tbl.c | 15 +- drivers/net/bnxt/tf_core/tf_msg.c | 347 +++++++++--- drivers/net/bnxt/tf_core/tf_rm.c | 14 +- drivers/net/bnxt/tf_core/tf_session.c | 161 ++++-- drivers/net/bnxt/tf_core/tf_sram_mgr.c | 51 +- drivers/net/bnxt/tf_core/tf_tbl.c | 62 ++- drivers/net/bnxt/tf_core/tf_tbl_sram.c | 103 +++- drivers/net/bnxt/tf_core/tf_tcam.c | 53 +- 17 files changed, 1217 insertions(+), 363 deletions(-) diff --git a/drivers/net/bnxt/bnxt_stats.c b/drivers/net/bnxt/bnxt_stats.c index 5e59afe79f..07d38668f3 100644 --- a/drivers/net/bnxt/bnxt_stats.c +++ b/drivers/net/bnxt/bnxt_stats.c @@ -1172,6 +1172,7 @@ int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) { struct bnxt *bp = eth_dev->data->dev_private; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; ret = is_bnxt_in_error(bp); @@ -1185,9 +1186,12 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) } ret = bnxt_hwrm_port_clr_stats(bp); - if (ret != 0) + if (ret != 0) { + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); PMD_DRV_LOG_LINE(ERR, "Failed to reset xstats: %s", - strerror(-ret)); + errmsg); + } bnxt_clear_prev_stat(bp); diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index e9b5739050..1b388792a3 100644 --- a/drivers/net/bnxt/rte_pmd_bnxt.c +++ b/drivers/net/bnxt/rte_pmd_bnxt.c @@ -136,6 +136,7 @@ int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -147,9 +148,11 @@ int rte_pmd_bnxt_set_vf_mac_addr(uint16_t port, uint16_t vf, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -176,6 +179,7 @@ int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf, { struct rte_eth_dev *eth_dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; uint32_t tot_rate = 0; uint64_t idx; @@ -189,9 +193,11 @@ int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -231,6 +237,7 @@ int rte_pmd_bnxt_set_vf_rate_limit(uint16_t port, uint16_t vf, int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct rte_eth_dev *dev; uint32_t func_flags; struct bnxt *bp; @@ -247,9 +254,11 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -291,6 +300,7 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct rte_eth_dev *dev; struct bnxt *bp; int rc; @@ -306,9 +316,11 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint16_t port, uint16_t vf, uint8_t on) rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -352,6 +364,7 @@ rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -363,9 +376,11 @@ rte_pmd_bnxt_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on) rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -395,6 +410,7 @@ int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; uint16_t flag = 0; struct bnxt *bp; int rc; @@ -407,9 +423,11 @@ int rte_pmd_bnxt_set_vf_rxmode(uint16_t port, uint16_t vf, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -589,6 +607,7 @@ int rte_pmd_bnxt_get_vf_stats(uint16_t port, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -598,9 +617,11 @@ int rte_pmd_bnxt_get_vf_stats(uint16_t port, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -625,6 +646,7 @@ int rte_pmd_bnxt_reset_vf_stats(uint16_t port, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -634,9 +656,11 @@ int rte_pmd_bnxt_reset_vf_stats(uint16_t port, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -659,6 +683,7 @@ int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id) { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -668,9 +693,11 @@ int rte_pmd_bnxt_get_vf_rx_status(uint16_t port, uint16_t vf_id) rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -694,6 +721,7 @@ int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -703,9 +731,11 @@ int rte_pmd_bnxt_get_vf_tx_drop_count(uint16_t port, uint16_t vf_id, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -734,6 +764,7 @@ int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct rte_ether_addr *addr, struct bnxt_filter_info *filter; struct bnxt_vnic_info vnic; struct rte_ether_addr dflt_mac; + char errmsg[RTE_STRERR_BUFSIZE]; int rc; dev = &rte_eth_devices[port]; @@ -742,9 +773,11 @@ int rte_pmd_bnxt_mac_addr_add(uint16_t port, struct rte_ether_addr *addr, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -814,6 +847,7 @@ rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct bnxt *bp; int rc; @@ -825,9 +859,11 @@ rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf, rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } @@ -856,6 +892,7 @@ rte_pmd_bnxt_set_vf_vlan_insert(uint16_t port, uint16_t vf, int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on) { struct rte_eth_dev_info dev_info; + char errmsg[RTE_STRERR_BUFSIZE]; struct rte_eth_dev *dev; uint32_t func_flags; struct bnxt *bp; @@ -869,9 +906,11 @@ int rte_pmd_bnxt_set_vf_persist_stats(uint16_t port, uint16_t vf, uint8_t on) dev = &rte_eth_devices[port]; rc = rte_eth_dev_info_get(port, &dev_info); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); PMD_DRV_LOG_LINE(ERR, "Error during getting device (port %u) info: %s", - port, strerror(-rc)); + port, errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c index 3a812bee3a..18c8ea3ff0 100644 --- a/drivers/net/bnxt/tf_core/tf_core.c +++ b/drivers/net/bnxt/tf_core/tf_core.c @@ -193,6 +193,7 @@ tf_close_session(struct tf *tfp) int tf_insert_em_entry(struct tf *tfp, struct tf_insert_em_entry_parms *parms) { + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session *tfs; struct tf_dev_info *dev; int rc; @@ -202,20 +203,24 @@ int tf_insert_em_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -229,10 +234,12 @@ int tf_insert_em_entry(struct tf *tfp, return -EINVAL; if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: EM insert failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -248,6 +255,7 @@ int tf_insert_em_entry(struct tf *tfp, int tf_delete_em_entry(struct tf *tfp, struct tf_delete_em_entry_parms *parms) { + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session *tfs; struct tf_dev_info *dev; int rc; @@ -258,20 +266,24 @@ int tf_delete_em_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -282,10 +294,12 @@ int tf_delete_em_entry(struct tf *tfp, rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: EM delete failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -304,26 +318,31 @@ int tf_get_global_cfg(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -335,19 +354,23 @@ int tf_get_global_cfg(struct tf *tfp, if (dev->ops->tf_dev_get_global_cfg == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_get_global_cfg(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Global Cfg get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -366,26 +389,31 @@ int tf_set_global_cfg(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -397,19 +425,23 @@ int tf_set_global_cfg(struct tf *tfp, if (dev->ops->tf_dev_set_global_cfg == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_set_global_cfg(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Global Cfg set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -423,6 +455,7 @@ tf_alloc_identifier(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_ident_alloc_parms aparms; uint16_t id; @@ -434,29 +467,35 @@ tf_alloc_identifier(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_alloc_ident == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } @@ -465,10 +504,12 @@ tf_alloc_identifier(struct tf *tfp, aparms.id = &id; rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Identifier allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -484,6 +525,7 @@ tf_free_identifier(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_ident_free_parms fparms; TF_CHECK_PARMS2(tfp, parms); @@ -494,29 +536,35 @@ tf_free_identifier(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_free_ident == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } @@ -526,10 +574,12 @@ tf_free_identifier(struct tf *tfp, fparms.ref_cnt = &parms->ref_cnt; rc = dev->ops->tf_dev_free_ident(tfp, &fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Identifier free failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -543,6 +593,7 @@ tf_search_identifier(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_ident_search_parms sparms; TF_CHECK_PARMS2(tfp, parms); @@ -553,29 +604,35 @@ tf_search_identifier(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_search_ident == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -586,10 +643,12 @@ tf_search_identifier(struct tf *tfp, sparms.ref_cnt = &parms->ref_cnt; rc = dev->ops->tf_dev_search_ident(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Identifier search failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -603,6 +662,7 @@ tf_search_tcam_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tcam_alloc_search_parms sparms; TF_CHECK_PARMS2(tfp, parms); @@ -612,29 +672,35 @@ tf_search_tcam_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_alloc_search_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -653,10 +719,12 @@ tf_search_tcam_entry(struct tf *tfp, rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -676,6 +744,7 @@ tf_alloc_tcam_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tcam_alloc_parms aparms; TF_CHECK_PARMS2(tfp, parms); @@ -685,29 +754,35 @@ tf_alloc_tcam_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_alloc_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -717,10 +792,12 @@ tf_alloc_tcam_entry(struct tf *tfp, aparms.priority = parms->priority; rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -736,6 +813,7 @@ tf_set_tcam_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tcam_set_parms sparms; TF_CHECK_PARMS2(tfp, parms); @@ -745,30 +823,36 @@ tf_set_tcam_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_set_tcam == NULL || dev->ops->tf_dev_word_align == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -783,10 +867,12 @@ tf_set_tcam_entry(struct tf *tfp, rc = dev->ops->tf_dev_set_tcam(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } TFP_DRV_LOG(DEBUG, @@ -804,6 +890,7 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tcam_get_parms gparms; TF_CHECK_PARMS2(tfp, parms); @@ -813,29 +900,35 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_get_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -850,10 +943,12 @@ tf_get_tcam_entry(struct tf *tfp __rte_unused, rc = dev->ops->tf_dev_get_tcam(tfp, &gparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } parms->key_sz_in_bits = gparms.key_size * 8; @@ -869,6 +964,7 @@ tf_free_tcam_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tcam_free_parms fparms; TF_CHECK_PARMS2(tfp, parms); @@ -878,29 +974,35 @@ tf_free_tcam_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_free_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -909,10 +1011,12 @@ tf_free_tcam_entry(struct tf *tfp, fparms.idx = parms->idx; rc = dev->ops->tf_dev_free_tcam(tfp, &fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM free failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -926,44 +1030,53 @@ tf_move_tcam_shared_entries(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_move_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_move_tcam(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM shared entries move failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -977,44 +1090,53 @@ tf_clear_tcam_shared_entries(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_clear_tcam == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_clear_tcam(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TCAM shared entries clear failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1028,6 +1150,7 @@ tf_alloc_tbl_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_alloc_parms aparms; uint32_t idx; @@ -1039,20 +1162,24 @@ tf_alloc_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1064,37 +1191,45 @@ tf_alloc_tbl_entry(struct tf *tfp, if (parms->type == TF_TBL_TYPE_EXT) { if (dev->ops->tf_dev_alloc_ext_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: External table allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) { rc = dev->ops->tf_dev_alloc_sram_tbl(tfp, &aparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM table allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else { rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table allocation failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } @@ -1111,6 +1246,7 @@ tf_free_tbl_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_free_parms fparms; TF_CHECK_PARMS2(tfp, parms); @@ -1121,20 +1257,24 @@ tf_free_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1146,38 +1286,46 @@ tf_free_tbl_entry(struct tf *tfp, if (parms->type == TF_TBL_TYPE_EXT) { if (dev->ops->tf_dev_free_ext_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table free failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) { rc = dev->ops->tf_dev_free_sram_tbl(tfp, &fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM table free failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else { rc = dev->ops->tf_dev_free_tbl(tfp, &fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table free failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } @@ -1191,6 +1339,7 @@ tf_set_tbl_entry(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_set_parms sparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -1201,20 +1350,24 @@ tf_set_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1228,46 +1381,56 @@ tf_set_tbl_entry(struct tf *tfp, if (parms->type == TF_TBL_TYPE_EXT) { if (dev->ops->tf_dev_set_ext_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) { rc = dev->ops->tf_dev_set_sram_tbl(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM table set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else { if (dev->ops->tf_dev_set_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_set_tbl(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } @@ -1282,6 +1445,7 @@ tf_get_tbl_entry(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_get_parms gparms; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -1292,20 +1456,24 @@ tf_get_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } gparms.dir = parms->dir; @@ -1317,28 +1485,34 @@ tf_get_tbl_entry(struct tf *tfp, if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) { rc = dev->ops->tf_dev_get_sram_tbl(tfp, &gparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM table get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } else { if (dev->ops->tf_dev_get_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_get_tbl(tfp, &gparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } } @@ -1353,6 +1527,7 @@ tf_bulk_get_tbl_entry(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_get_bulk_parms bparms; TF_CHECK_PARMS2(tfp, parms); @@ -1363,20 +1538,24 @@ tf_bulk_get_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1390,38 +1569,46 @@ tf_bulk_get_tbl_entry(struct tf *tfp, if (parms->type == TF_TBL_TYPE_EXT) { /* Not supported, yet */ rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, External table type not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) { rc = dev->ops->tf_dev_get_bulk_sram_tbl(tfp, &bparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM table bulk get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); } return rc; } if (dev->ops->tf_dev_get_bulk_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Table get bulk failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } return rc; @@ -1433,26 +1620,31 @@ int tf_get_shared_tbl_increment(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1460,19 +1652,23 @@ int tf_get_shared_tbl_increment(struct tf *tfp, if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Get table increment not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1485,6 +1681,7 @@ tf_alloc_tbl_scope(struct tf *tfp, { struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; int rc; TF_CHECK_PARMS2(tfp, parms); @@ -1492,18 +1689,22 @@ tf_alloc_tbl_scope(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1523,6 +1724,7 @@ tf_map_tbl_scope(struct tf *tfp, { struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; int rc; TF_CHECK_PARMS2(tfp, parms); @@ -1530,18 +1732,22 @@ tf_map_tbl_scope(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1562,6 +1768,7 @@ tf_free_tbl_scope(struct tf *tfp, { struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; int rc; TF_CHECK_PARMS2(tfp, parms); @@ -1569,18 +1776,22 @@ tf_free_tbl_scope(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1602,6 +1813,7 @@ tf_set_if_tbl_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_if_tbl_set_parms sparms = { 0 }; TF_CHECK_PARMS2(tfp, parms); @@ -1609,29 +1821,35 @@ tf_set_if_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_set_if_tbl == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1643,10 +1861,12 @@ tf_set_if_tbl_entry(struct tf *tfp, rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: If_tbl set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1660,6 +1880,7 @@ tf_get_if_tbl_entry(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_if_tbl_get_parms gparms = { 0 }; TF_CHECK_PARMS2(tfp, parms); @@ -1667,29 +1888,35 @@ tf_get_if_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } if (dev->ops->tf_dev_get_if_tbl == NULL) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); rc = -EOPNOTSUPP; TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1701,10 +1928,12 @@ tf_get_if_tbl_entry(struct tf *tfp, rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: If_tbl get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1717,24 +1946,29 @@ int tf_get_session_info(struct tf *tfp, int rc; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1742,62 +1976,78 @@ int tf_get_session_info(struct tf *tfp, if (dev->ops->tf_dev_get_ident_resc_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Ident get resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); } if (dev->ops->tf_dev_get_tbl_resc_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Tbl get resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); } if (dev->ops->tf_dev_get_tcam_resc_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "TCAM get resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); } if (dev->ops->tf_dev_get_em_resc_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "EM get resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); } return 0; @@ -1839,6 +2089,7 @@ int tf_query_sram_resources(struct tf *tfp, struct tf_dev_info dev; uint16_t max_types; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_rm_resc_req_entry *query; enum tf_rm_resc_resv_strategy resv_strategy; @@ -1858,19 +2109,23 @@ int tf_query_sram_resources(struct tf *tfp, if (dev.ops->tf_dev_get_max_types == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } /* Need device max number of elements for the RM QCAPS */ rc = dev.ops->tf_dev_get_max_types(tfp, &max_types); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Get SRAM resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1898,10 +2153,12 @@ int tf_query_sram_resources(struct tf *tfp, if (dev.ops->tf_dev_get_sram_resources == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return -EOPNOTSUPP; } @@ -1909,9 +2166,11 @@ int tf_query_sram_resources(struct tf *tfp, parms->bank_resc_count, &parms->dynamic_sram_capable); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Get SRAM resc info failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1923,6 +2182,7 @@ int tf_set_sram_policy(struct tf *tfp, { int rc = 0; struct tf_dev_info dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -1940,19 +2200,23 @@ int tf_set_sram_policy(struct tf *tfp, if (dev.ops->tf_dev_set_sram_policy == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = dev.ops->tf_dev_set_sram_policy(parms->dir, parms->bank_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM policy set failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1964,6 +2228,7 @@ int tf_get_sram_policy(struct tf *tfp, { int rc = 0; struct tf_dev_info dev; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -1981,19 +2246,23 @@ int tf_get_sram_policy(struct tf *tfp, if (dev.ops->tf_dev_get_sram_policy == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = dev.ops->tf_dev_get_sram_policy(parms->dir, parms->bank_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: SRAM policy get failed, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c index c518150d1f..2d5e32816c 100644 --- a/drivers/net/bnxt/tf_core/tf_em_common.c +++ b/drivers/net/bnxt/tf_core/tf_em_common.c @@ -43,6 +43,7 @@ tf_create_tbl_pool_external(enum tf_dir dir, uint32_t i; int32_t j; int rc = 0; + char errmsg[RTE_STRERR_BUFSIZE]; struct stack *pool = &tbl_scope_cb->ext_act_pool[dir]; parms.nitems = num_entries; @@ -50,8 +51,10 @@ tf_create_tbl_pool_external(enum tf_dir dir, parms.alignment = 0; if (tfp_calloc(&parms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "%s: TBL: external pool failure %s\n", - tf_dir_2_str(dir), strerror(ENOMEM)); + tf_dir_2_str(dir), errmsg); return -ENOMEM; } @@ -60,8 +63,10 @@ tf_create_tbl_pool_external(enum tf_dir dir, rc = stack_init(num_entries, parms.mem_va, pool); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: TBL: stack init failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); + tf_dir_2_str(dir), errmsg); goto cleanup; } @@ -77,8 +82,10 @@ tf_create_tbl_pool_external(enum tf_dir dir, for (i = 0; i < num_entries; i++) { rc = stack_push(pool, j); if (rc != 0) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); + tf_dir_2_str(dir), errmsg); goto cleanup; } @@ -92,8 +99,10 @@ tf_create_tbl_pool_external(enum tf_dir dir, if (!stack_is_full(pool)) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s TBL: stack failure %s\n", - tf_dir_2_str(dir), strerror(-rc)); + tf_dir_2_str(dir), errmsg); goto cleanup; } return 0; @@ -913,6 +922,7 @@ tf_em_ext_common_bind(struct tf *tfp, struct tf_rm_create_db_parms db_cfg = { 0 }; struct em_ext_db *ext_db; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -920,8 +930,10 @@ tf_em_ext_common_bind(struct tf *tfp, cparms.size = sizeof(struct em_ext_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "em_ext_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -974,30 +986,37 @@ tf_em_ext_common_unbind(struct tf *tfp) struct tf_tbl_scope_cb *tbl_scope_cb = NULL; void *ext_ptr = NULL; struct tf_free_tbl_scope_parms tparms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS1(tfp); rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_em_ext_db(tfp, &ext_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1129,6 +1148,7 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, { int rc = 0; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_scope_cb *tbl_scope_cb; struct tf_global_cfg_parms gcfg_parms = { 0 }; struct tfp_calloc_parms aparms; @@ -1155,9 +1175,11 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, if (dev->ops->tf_dev_map_tbl_scope == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Map table scope operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1166,15 +1188,19 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, aparms.alignment = 0; if (tfp_calloc(&aparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "Map tbl scope alloc data error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } data = aparms.mem_va; if (tfp_calloc(&aparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "Map tbl scope alloc mask error %s\n", - strerror(ENOMEM)); + errmsg); rc = -ENOMEM; goto clean; } @@ -1186,9 +1212,11 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, sz_in_bytes); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Map table scope config failure, rc:%s\n", - strerror(-rc)); + errmsg); goto cleaner; } @@ -1201,9 +1229,11 @@ int tf_em_ext_map_tbl_scope(struct tf *tfp, rc = tf_msg_set_global_cfg(tfp, &gcfg_parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Map tbl scope, set failed, rc:%s\n", - strerror(-rc)); + errmsg); } cleaner: tfp_free(mask); diff --git a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c index 9c527e152d..f18097a76b 100644 --- a/drivers/net/bnxt/tf_core/tf_em_hash_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_hash_internal.c @@ -124,13 +124,16 @@ tf_em_hash_delete_int_entry(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct dpool *pool; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -158,14 +161,17 @@ tf_em_move_int_entry(struct tf *tfp, int rc = 0; struct dpool *pool; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c index 9efffe4ee5..1b31032fe8 100644 --- a/drivers/net/bnxt/tf_core/tf_em_host.c +++ b/drivers/net/bnxt/tf_core/tf_em_host.c @@ -168,6 +168,7 @@ static int tf_em_alloc_page_table(struct hcapi_cfa_em_table *tbl) { struct hcapi_cfa_em_page_tbl *tp; + char errmsg[RTE_STRERR_BUFSIZE]; int rc = 0; int i; uint32_t j; @@ -179,10 +180,12 @@ tf_em_alloc_page_table(struct hcapi_cfa_em_table *tbl) tbl->page_cnt[i], TF_EM_PAGE_SIZE); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(WARNING, "Failed to allocate page table: lvl: %d, rc:%s\n", i, - strerror(-rc)); + errmsg); goto cleanup; } @@ -365,6 +368,7 @@ tf_em_ext_alloc(struct tf *tfp, { int rc; enum tf_dir dir; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_scope_cb *tbl_scope_cb; struct hcapi_cfa_em_table *em_tables; struct tf_free_tbl_scope_parms free_parms; @@ -378,25 +382,31 @@ tf_em_ext_alloc(struct tf *tfp, rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_em_ext_db(tfp, &ext_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } ext_db = (struct em_ext_db *)ext_ptr; rc = tfp_get_pf(tfp, &pf); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "EEM: PF query error rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } @@ -417,10 +427,12 @@ tf_em_ext_alloc(struct tf *tfp, cparms.alignment = 0; rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); /* Log error */ TFP_DRV_LOG(ERR, "Failed to allocate session table scope, rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } @@ -433,10 +445,12 @@ tf_em_ext_alloc(struct tf *tfp, dir, &tbl_scope_cb->em_caps[dir]); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "EEM: Unable to query for EEM capability," " rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup_ts; } } @@ -453,10 +467,12 @@ tf_em_ext_alloc(struct tf *tfp, */ rc = tf_em_ctx_reg(tfp, tbl_scope_cb, dir); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "EEM: Unable to register for EEM ctx," " rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup_ts; } @@ -470,10 +486,12 @@ tf_em_ext_alloc(struct tf *tfp, parms->hw_flow_cache_flush_timer, dir); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "TBL: Unable to configure EEM in firmware" " rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup_full; } @@ -482,10 +500,12 @@ tf_em_ext_alloc(struct tf *tfp, HWRM_TF_EXT_EM_OP_INPUT_OP_EXT_EM_ENABLE); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "EEM: Unable to enable EEM in firmware" " rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup_full; } @@ -498,10 +518,12 @@ tf_em_ext_alloc(struct tf *tfp, em_tables[TF_RECORD_TABLE].num_entries, em_tables[TF_RECORD_TABLE].entry_size); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s TBL: Unable to allocate idx pools %s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); goto cleanup_full; } } @@ -538,6 +560,7 @@ tf_em_ext_free(struct tf *tfp, { int rc = 0; enum tf_dir dir; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_scope_cb *tbl_scope_cb; struct tf_session *tfs; struct em_ext_db *ext_db = NULL; @@ -546,16 +569,20 @@ tf_em_ext_free(struct tf *tfp, rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tf_session, rc:%s\n", - strerror(-rc)); + errmsg); return -EINVAL; } rc = tf_session_get_em_ext_db(tfp, &ext_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } ext_db = (struct em_ext_db *)ext_ptr; diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c index 7f7a663789..0145c4778d 100644 --- a/drivers/net/bnxt/tf_core/tf_em_internal.c +++ b/drivers/net/bnxt/tf_core/tf_em_internal.c @@ -38,6 +38,7 @@ tf_em_insert_int_entry(struct tf *tfp, uint32_t gfid; uint16_t rptr_index = 0; uint8_t rptr_entry = 0; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t num_of_entries = 0; struct tf_session *tfs; struct dpool *pool; @@ -46,10 +47,12 @@ tf_em_insert_int_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -107,13 +110,16 @@ tf_em_delete_int_entry(struct tf *tfp, int rc = 0; struct tf_session *tfs; struct dpool *pool; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -136,6 +142,7 @@ tf_em_move_callback(void *user_data, int rc; struct tf *tfp = (struct tf *)user_data; struct tf_move_em_entry_parms parms; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_dev_info *dev; struct tf_session *tfs; @@ -150,20 +157,24 @@ tf_em_move_callback(void *user_data, /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(parms.dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(parms.dir), - strerror(-rc)); + errmsg); return rc; } @@ -184,6 +195,7 @@ tf_em_int_bind(struct tf *tfp, int i; struct tf_rm_create_db_parms db_cfg = { 0 }; struct tf_rm_get_alloc_info_parms iparms; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_rm_alloc_info info; struct em_rm_db *em_db; struct tfp_calloc_parms cparms; @@ -201,8 +213,10 @@ tf_em_int_bind(struct tf *tfp, cparms.size = sizeof(struct em_rm_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "em_rm_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -228,11 +242,13 @@ tf_em_int_bind(struct tf *tfp, if (db_cfg.alloc_cnt[TF_EM_TBL_TYPE_EM_RECORD] % TF_SESSION_EM_ENTRY_SIZE != 0) { rc = -ENOMEM; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, EM Allocation must be in blocks of %d, failure %s\n", tf_dir_2_str(i), TF_SESSION_EM_ENTRY_SIZE, - strerror(-rc)); + errmsg); return rc; } @@ -275,10 +291,12 @@ tf_em_int_bind(struct tf *tfp, rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, EM stack allocation failure %s\n", tf_dir_2_str(i), - strerror(-rc)); + errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_global_cfg.c b/drivers/net/bnxt/tf_core/tf_global_cfg.c index 3a8030a2fb..356165de89 100644 --- a/drivers/net/bnxt/tf_core/tf_global_cfg.c +++ b/drivers/net/bnxt/tf_core/tf_global_cfg.c @@ -74,6 +74,7 @@ tf_global_cfg_bind(struct tf *tfp, struct tf_global_cfg_cfg_parms *parms) { struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_global_cfg_db *global_cfg_db; TF_CHECK_PARMS2(tfp, parms); @@ -82,8 +83,10 @@ tf_global_cfg_bind(struct tf *tfp, cparms.size = sizeof(struct tf_global_cfg_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "global_rm_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -121,6 +124,7 @@ tf_global_cfg_set(struct tf *tfp, int rc; struct tf_global_cfg_get_hcapi_parms hparms; struct tf_global_cfg_db *global_cfg_db_ptr; + char errmsg[RTE_STRERR_BUFSIZE]; uint16_t hcapi_type; TF_CHECK_PARMS3(tfp, parms, parms->config); @@ -137,21 +141,25 @@ tf_global_cfg_set(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_global_cfg_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); return rc; } rc = tf_msg_set_global_cfg(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Set failed, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); } return 0; @@ -165,6 +173,7 @@ tf_global_cfg_get(struct tf *tfp, int rc; struct tf_global_cfg_get_hcapi_parms hparms; struct tf_global_cfg_db *global_cfg_db_ptr; + char errmsg[RTE_STRERR_BUFSIZE]; uint16_t hcapi_type; TF_CHECK_PARMS3(tfp, parms, parms->config); @@ -181,22 +190,26 @@ tf_global_cfg_get(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_global_cfg_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); return rc; } /* Get the entry */ rc = tf_msg_get_global_cfg(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Get failed, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); } return 0; diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c index 7d9d9595dd..b89d9c0da0 100644 --- a/drivers/net/bnxt/tf_core/tf_identifier.c +++ b/drivers/net/bnxt/tf_core/tf_identifier.c @@ -24,6 +24,7 @@ tf_ident_bind(struct tf *tfp, struct tf_rm_create_db_parms db_cfg = { 0 }; struct ident_rm_db *ident_db; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session *tfs; TF_CHECK_PARMS2(tfp, parms); @@ -38,8 +39,10 @@ tf_ident_bind(struct tf *tfp, cparms.size = sizeof(struct ident_rm_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "ident_rm_db alloc error %s\n", - strerror(ENOMEM)); + rte_strerror(ENOMEM)); return -ENOMEM; } @@ -114,6 +117,7 @@ tf_ident_alloc(struct tf *tfp __rte_unused, int rc; uint32_t id; uint32_t base_id; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_rm_allocate_parms aparms = { 0 }; struct ident_rm_db *ident_db; void *ident_db_ptr = NULL; @@ -122,9 +126,11 @@ tf_ident_alloc(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get ident_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } ident_db = (struct ident_rm_db *)ident_db_ptr; @@ -153,6 +159,7 @@ tf_ident_free(struct tf *tfp __rte_unused, int rc; struct tf_rm_is_allocated_parms aparms = { 0 }; struct tf_rm_free_parms fparms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; int allocated = 0; uint32_t base_id; struct ident_rm_db *ident_db; @@ -162,9 +169,11 @@ tf_ident_free(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get ident_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } ident_db = (struct ident_rm_db *)ident_db_ptr; @@ -211,6 +220,7 @@ tf_ident_search(struct tf *tfp __rte_unused, { int rc; struct tf_rm_is_allocated_parms aparms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; int allocated = 0; uint32_t base_id; struct ident_rm_db *ident_db; @@ -220,9 +230,11 @@ tf_ident_search(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_IDENTIFIER, &ident_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get ident_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } ident_db = (struct ident_rm_db *)ident_db_ptr; diff --git a/drivers/net/bnxt/tf_core/tf_if_tbl.c b/drivers/net/bnxt/tf_core/tf_if_tbl.c index 578d361417..cbbade789e 100644 --- a/drivers/net/bnxt/tf_core/tf_if_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_if_tbl.c @@ -57,6 +57,7 @@ tf_if_tbl_bind(struct tf *tfp, { struct tfp_calloc_parms cparms; struct tf_if_tbl_db *if_tbl_db; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -64,8 +65,10 @@ tf_if_tbl_bind(struct tf *tfp, cparms.size = sizeof(struct tf_if_tbl_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "if_tbl_rm_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -111,6 +114,7 @@ tf_if_tbl_set(struct tf *tfp, struct tf_if_tbl_set_parms *parms) { int rc; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_if_tbl_db *if_tbl_db_ptr = NULL; struct tf_if_tbl_get_hcapi_parms hparms; @@ -139,11 +143,13 @@ tf_if_tbl_set(struct tf *tfp, rc = tf_msg_set_if_tbl_entry(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, If Tbl set failed, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); } return 0; @@ -154,6 +160,7 @@ tf_if_tbl_get(struct tf *tfp, struct tf_if_tbl_get_parms *parms) { int rc = 0; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_if_tbl_db *if_tbl_db_ptr = NULL; struct tf_if_tbl_get_hcapi_parms hparms; @@ -183,11 +190,13 @@ tf_if_tbl_get(struct tf *tfp, /* Get the entry */ rc = tf_msg_get_if_tbl_entry(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, If Tbl get failed, type:%d, rc:%s\n", tf_dir_2_str(parms->dir), parms->type, - strerror(-rc)); + errmsg); } return 0; diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c index 1c66c7e01a..9793918519 100644 --- a/drivers/net/bnxt/tf_core/tf_msg.c +++ b/drivers/net/bnxt/tf_core/tf_msg.c @@ -205,6 +205,7 @@ tf_msg_session_client_register(struct tf *tfp, struct hwrm_tf_session_register_input req = { 0 }; struct hwrm_tf_session_register_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_dev_info *dev; char *session_name; @@ -214,17 +215,21 @@ tf_msg_session_client_register(struct tf *tfp, /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -283,23 +288,28 @@ tf_msg_session_client_unregister(struct tf *tfp, struct hwrm_tf_session_unregister_input req = { 0 }; struct hwrm_tf_session_unregister_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_dev_info *dev; /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -352,6 +362,7 @@ tf_msg_session_qcfg(struct tf *tfp) struct hwrm_tf_session_qcfg_input req = { 0 }; struct hwrm_tf_session_qcfg_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; @@ -359,26 +370,32 @@ tf_msg_session_qcfg(struct tf *tfp) /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -413,6 +430,7 @@ tf_msg_session_resc_qcaps(struct tf *tfp, struct hwrm_tf_session_resc_qcaps_output resp = { 0 }; struct tf_msg_dma_buf qcaps_buf = { 0 }; struct tf_rm_resc_req_entry *data; + char errmsg[RTE_STRERR_BUFSIZE]; int dma_size; TF_CHECK_PARMS3(tfp, query, resv_strategy); @@ -444,10 +462,12 @@ tf_msg_session_resc_qcaps(struct tf *tfp, * Should always get expected number of entries */ if (tfp_le_to_cpu_32(resp.size) != size) { + if (strerror_r(EINVAL, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", EINVAL); TFP_DRV_LOG(WARNING, "%s: QCAPS message size error, rc:%s, request %d vs response %d\n", tf_dir_2_str(dir), - strerror(EINVAL), + errmsg, size, resp.size); } @@ -490,15 +510,18 @@ tf_msg_session_resc_alloc(struct tf *tfp, struct tf_msg_dma_buf resv_buf = { 0 }; struct tf_rm_resc_req_entry *req_data; struct tf_rm_resc_entry *resv_data; + char errmsg[RTE_STRERR_BUFSIZE]; int dma_size; struct tf_session *tfs; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -506,10 +529,12 @@ tf_msg_session_resc_alloc(struct tf *tfp, rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -556,10 +581,12 @@ tf_msg_session_resc_alloc(struct tf *tfp, * Should always get expected number of entries */ if (tfp_le_to_cpu_32(resp.size) != size) { + if (strerror_r(EINVAL, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", EINVAL); TFP_DRV_LOG(ERR, "%s: Alloc message size error, rc:%s\n", tf_dir_2_str(dir), - strerror(EINVAL)); + errmsg); rc = -EINVAL; goto cleanup; } @@ -597,15 +624,18 @@ tf_msg_session_resc_info(struct tf *tfp, struct tf_msg_dma_buf resv_buf = { 0 }; struct tf_rm_resc_req_entry *req_data; struct tf_rm_resc_entry *resv_data; + char errmsg[RTE_STRERR_BUFSIZE]; int dma_size; struct tf_session *tfs; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -613,10 +643,12 @@ tf_msg_session_resc_info(struct tf *tfp, rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -663,10 +695,12 @@ tf_msg_session_resc_info(struct tf *tfp, * Should always get expected number of entries */ if (tfp_le_to_cpu_32(resp.size) != size) { + if (strerror_r(EINVAL, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", EINVAL); TFP_DRV_LOG(ERR, "%s: Alloc message size error, rc:%s\n", tf_dir_2_str(dir), - strerror(EINVAL)); + errmsg); rc = -EINVAL; goto cleanup; } @@ -703,16 +737,19 @@ tf_msg_session_resc_flush(struct tf *tfp, int dma_size; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, resv); /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -722,16 +759,18 @@ tf_msg_session_resc_flush(struct tf *tfp, TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -787,6 +826,7 @@ tf_msg_insert_em_internal_entry(struct tf *tfp, uint8_t msg_key_size; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; RTE_BUILD_BUG_ON(sizeof(struct hwrm_tf_em_insert_input) != TF_MSG_SIZE_HWRM_TF_EM_INSERT); @@ -794,29 +834,35 @@ tf_msg_insert_em_internal_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -827,10 +873,12 @@ tf_msg_insert_em_internal_entry(struct tf *tfp, msg_key_size = (em_parms->key_sz_in_bits + 7) / 8; if (msg_key_size > TF_MSG_EM_INSERT_KEY_SIZE) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Invalid parameters for msg type, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -886,33 +934,40 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp, uint8_t msg_record_size; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -924,10 +979,12 @@ tf_msg_hash_insert_em_internal_entry(struct tf *tfp, if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Record size to large, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -975,33 +1032,40 @@ tf_msg_delete_em_entry(struct tf *tfp, uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1043,33 +1107,40 @@ tf_msg_move_em_entry(struct tf *tfp, uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(em_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1114,22 +1185,27 @@ int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp, struct tf_dev_info *dev; struct tf_session *tfs; uint32_t fw_se_id; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the session information */ @@ -1148,8 +1224,10 @@ int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp, parms.mailbox = dev->ops->tf_dev_get_mailbox(); rc = tfp_send_msg_direct(tf_session_get_bp(tfp), &parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed ext_em_alloc error rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1174,22 +1252,27 @@ int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp, struct tf_dev_info *dev; struct tf_session *tfs; uint32_t fw_se_id; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the session information */ @@ -1222,6 +1305,7 @@ tf_msg_em_mem_rgtr(struct tf *tfp, struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 }; struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_dev_info *dev; struct tf_session *tfs; uint32_t fw_se_id; @@ -1229,18 +1313,22 @@ tf_msg_em_mem_rgtr(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } fw_se_id = tfs->session_id.internal.fw_session_id; @@ -1275,6 +1363,7 @@ tf_msg_em_mem_unrgtr(struct tf *tfp, struct hwrm_tf_ctxt_mem_unrgtr_input req = {0}; struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0}; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_dev_info *dev; struct tf_session *tfs; uint32_t fw_se_id; @@ -1282,18 +1371,22 @@ tf_msg_em_mem_unrgtr(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1324,6 +1417,7 @@ tf_msg_em_qcaps(struct tf *tfp, struct hwrm_tf_ext_em_qcaps_output resp = { 0 }; uint32_t flags; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_dev_info *dev; struct tf_session *tfs; uint32_t fw_se_id; @@ -1331,10 +1425,12 @@ tf_msg_em_qcaps(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } fw_se_id = tfs->session_id.internal.fw_session_id; @@ -1342,10 +1438,12 @@ tf_msg_em_qcaps(struct tf *tfp, /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -1392,26 +1490,31 @@ tf_msg_em_cfg(struct tf *tfp, struct hwrm_tf_ext_em_cfg_output resp = {0}; uint32_t flags; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_dev_info *dev; struct tf_session *tfs; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -1453,6 +1556,7 @@ tf_msg_ext_em_cfg(struct tf *tfp, struct hwrm_tf_ext_em_cfg_input req = {0}; struct hwrm_tf_ext_em_cfg_output resp = {0}; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint32_t flags; struct tf_dev_info *dev; struct tf_session *tfs; @@ -1462,20 +1566,24 @@ tf_msg_ext_em_cfg(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } fw_se_id = tfs->session_id.internal.fw_session_id; @@ -1527,24 +1635,29 @@ tf_msg_em_op(struct tf *tfp, struct tfp_send_msg_parms parms = { 0 }; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -1575,6 +1688,7 @@ tf_msg_tcam_entry_set(struct tf *tfp, struct hwrm_tf_tcam_set_input req = { 0 }; struct hwrm_tf_tcam_set_output resp = { 0 }; struct tf_msg_dma_buf buf = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t *data = NULL; int data_size = 0; uint8_t fw_session_id; @@ -1583,18 +1697,22 @@ tf_msg_tcam_entry_set(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1656,24 +1774,29 @@ tf_msg_tcam_entry_get(struct tf *tfp, struct tfp_send_msg_parms mparms = { 0 }; struct hwrm_tf_tcam_get_input req = { 0 }; struct hwrm_tf_tcam_get_output resp = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_session *tfs; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1700,12 +1823,14 @@ tf_msg_tcam_entry_get(struct tf *tfp, if (parms->key_size < resp.key_size || parms->result_size < resp.result_size) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Key buffer(%d) is smaller than the key(%d), rc:%s\n", tf_dir_2_str(parms->dir), parms->key_size, resp.key_size, - strerror(-rc)); + errmsg); return rc; } parms->key_size = resp.key_size; @@ -1726,6 +1851,7 @@ tf_msg_tcam_entry_free(struct tf *tfp, struct hwrm_tf_tcam_free_input req = { 0 }; struct hwrm_tf_tcam_free_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_session *tfs; @@ -1734,16 +1860,18 @@ tf_msg_tcam_entry_free(struct tf *tfp, if (rc) { TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(in_parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1780,6 +1908,7 @@ tf_msg_set_tbl_entry(struct tf *tfp, struct hwrm_tf_tbl_type_set_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; struct tf_msg_dma_buf buf = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; @@ -1790,29 +1919,35 @@ tf_msg_set_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } @@ -1866,6 +2001,7 @@ tf_msg_get_tbl_entry(struct tf *tfp, struct hwrm_tf_tbl_type_get_input req = { 0 }; struct hwrm_tf_tbl_type_get_output resp = { 0 }; struct tfp_send_msg_parms parms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; @@ -1874,29 +2010,35 @@ tf_msg_get_tbl_entry(struct tf *tfp, /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } flags = (dir == TF_DIR_TX ? @@ -1957,33 +2099,40 @@ tf_msg_get_global_cfg(struct tf *tfp, uint16_t resp_size = 0; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } @@ -2036,33 +2185,40 @@ tf_msg_set_global_cfg(struct tf *tfp, uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } @@ -2079,10 +2235,12 @@ tf_msg_set_global_cfg(struct tf *tfp, /* Check for data size conformity */ if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Invalid parameters for msg type, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } @@ -2133,33 +2291,40 @@ tf_msg_bulk_get_tbl_entry(struct tf *tfp, struct tf_dev_info *dev; struct tf_session *tfs; uint32_t flags = 0; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Unable to lookup FW id, rc:%s\n", tf_dir_2_str(dir), - strerror(-rc)); + errmsg); return rc; } flags = (dir == TF_DIR_TX ? @@ -2210,24 +2375,29 @@ tf_msg_get_if_tbl_entry(struct tf *tfp, uint32_t flags = 0; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup device, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } @@ -2271,14 +2441,17 @@ tf_msg_set_if_tbl_entry(struct tf *tfp, uint32_t flags = 0; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to lookup session, rc:%s\n", tf_dir_2_str(params->dir), - strerror(-rc)); + errmsg); return rc; } @@ -2360,30 +2533,37 @@ tf_msg_session_set_hotup_state(struct tf *tfp, uint16_t state) uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -2415,30 +2595,37 @@ tf_msg_session_get_hotup_state(struct tf *tfp, uint8_t fw_session_id; struct tf_dev_info *dev; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; /* Retrieve the session information */ rc = tf_session_get_session_internal(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } /* Retrieve the device information */ rc = tf_session_get_device(tfs, &dev); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup device, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c index 9b85f5397d..8d6ef5277c 100644 --- a/drivers/net/bnxt/tf_core/tf_rm.c +++ b/drivers/net/bnxt/tf_core/tf_rm.c @@ -1045,6 +1045,7 @@ tf_rm_get_pool(struct tf_rm_new_db *rm_db, { int rc = 0; uint16_t tmp_subtype = subtype; + char errmsg[RTE_STRERR_BUFSIZE]; /* If we are a child, get the parent table index */ if (rm_db->db[subtype].cfg_type == TF_RM_ELEM_CFG_HCAPI_BA_CHILD) @@ -1055,11 +1056,13 @@ tf_rm_get_pool(struct tf_rm_new_db *rm_db, /* Bail out if the pool is not valid, should never happen */ if (rm_db->db[tmp_subtype].pool == NULL) { rc = -ENOTSUP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Invalid pool for this type:%d, rc:%s\n", tf_dir_2_str(rm_db->dir), tmp_subtype, - strerror(-rc)); + errmsg); return rc; } *new_subtype = tmp_subtype; @@ -1073,6 +1076,7 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms) int id; uint32_t index; struct tf_rm_new_db *rm_db; + char errmsg[RTE_STRERR_BUFSIZE]; enum tf_rm_elem_cfg_type cfg_type; struct bitalloc *pool; uint16_t subtype; @@ -1103,10 +1107,12 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms) id = ba_alloc(pool); if (id == BA_FAIL) { rc = -ENOMEM; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Allocation failed, rc:%s\n", tf_dir_2_str(rm_db->dir), - strerror(-rc)); + errmsg); return rc; } @@ -1117,10 +1123,12 @@ tf_rm_allocate(struct tf_rm_allocate_parms *parms) id, &index); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Alloc adjust of base index failed, rc:%s\n", tf_dir_2_str(rm_db->dir), - strerror(-rc)); + errmsg); return -EINVAL; } diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c index 253d716572..bd047643cf 100644 --- a/drivers/net/bnxt/tf_core/tf_session.c +++ b/drivers/net/bnxt/tf_core/tf_session.c @@ -60,6 +60,7 @@ tf_session_create(struct tf *tfp, char *shared_name; char *tcam_session_name; char *pool_session_name; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -75,14 +76,19 @@ tf_session_create(struct tf *tfp, &shared_session_creator); if (rc) { /* Log error */ - if (rc == -EEXIST) + if (rc == -EEXIST) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session is already open, rc:%s\n", - strerror(-rc)); - else + errmsg); + } else { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Open message send failed, rc:%s\n", - strerror(-rc)); + errmsg); + } parms->open_cfg->session_id.id = TF_FW_SESSION_ID_INVALID; return rc; @@ -94,10 +100,12 @@ tf_session_create(struct tf *tfp, cparms.alignment = 0; rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); /* Log error */ TFP_DRV_LOG(ERR, "Failed to allocate session info, rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } tfp->session = (struct tf_session_info *)cparms.mem_va; @@ -108,10 +116,12 @@ tf_session_create(struct tf *tfp, cparms.alignment = 0; rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); /* Log error */ TFP_DRV_LOG(ERR, "Failed to allocate session data, rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } tfp->session->core_data = cparms.mem_va; @@ -151,10 +161,12 @@ tf_session_create(struct tf *tfp, cparms.alignment = 0; rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); /* Log error */ TFP_DRV_LOG(ERR, "Failed to allocate session client, rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } client = cparms.mem_va; @@ -224,9 +236,11 @@ tf_session_create(struct tf *tfp, dev.ops->tf_dev_get_mailbox()); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "FW Session close failed, rc:%s\n", - strerror(-rc)); + errmsg); } if (tfp->session) { tfp_free(tfp->session->core_data); @@ -259,6 +273,7 @@ tf_session_client_create(struct tf *tfp, struct tf_session *session = NULL; struct tf_session_client *client; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; union tf_session_client_id session_client_id; TF_CHECK_PARMS2(tfp, parms); @@ -266,9 +281,11 @@ tf_session_client_create(struct tf *tfp, /* Using internal version as session client may not exist yet */ rc = tf_session_get_session_internal(tfp, &session); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -287,9 +304,11 @@ tf_session_client_create(struct tf *tfp, parms->ctrl_chan_name, &session_client_id.internal.fw_session_client_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to create client on session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -301,9 +320,11 @@ tf_session_client_create(struct tf *tfp, cparms.alignment = 0; rc = tfp_calloc(&cparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to allocate session client, rc:%s\n", - strerror(-rc)); + errmsg); goto cleanup; } client = cparms.mem_va; @@ -318,9 +339,11 @@ tf_session_client_create(struct tf *tfp, (tfp, &session_client_id.internal.fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session Firmware id lookup failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -365,15 +388,18 @@ tf_session_client_destroy(struct tf *tfp, { int rc; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session_client *client; TF_CHECK_PARMS2(tfp, parms); rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to lookup session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -403,9 +429,11 @@ tf_session_client_destroy(struct tf *tfp, * thus we remove from the session. */ if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Client destroy on FW Failed, rc:%s\n", - strerror(-rc)); + errmsg); } ll_delete(&tfs->client_ll, &client->ll_entry); @@ -423,6 +451,7 @@ tf_session_open_session(struct tf *tfp, struct tf_session_open_session_parms *parms) { int rc; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session_client_create_parms scparms; TF_CHECK_PARMS3(tfp, parms, parms->open_cfg->bp); @@ -432,10 +461,12 @@ tf_session_open_session(struct tf *tfp, if (tfp->session == NULL) { rc = tf_session_create(tfp, parms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to create session, ctrl_chan_name:%s, rc:%s\n", parms->open_cfg->ctrl_chan_name, - strerror(-rc)); + errmsg); return rc; } @@ -454,10 +485,12 @@ tf_session_open_session(struct tf *tfp, */ rc = tf_session_client_create(tfp, &scparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to create client on session 0x%x, rc:%s\n", parms->open_cfg->session_id.id, - strerror(-rc)); + errmsg); return rc; } @@ -475,12 +508,15 @@ tf_session_attach_session(struct tf *tfp __rte_unused, struct tf_session_attach_session_parms *parms __rte_unused) { int rc = -EOPNOTSUPP; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Attach not yet supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -492,6 +528,7 @@ tf_session_close_session(struct tf *tfp, struct tf_session *tfs = NULL; struct tf_session_client *client; struct tf_dev_info *tfd = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_session_client_destroy_parms scdparms; uint16_t fid; uint8_t fw_session_id = 1; @@ -501,17 +538,21 @@ tf_session_close_session(struct tf *tfp, rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session lookup failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (tfs->session_id.id == TF_SESSION_ID_INVALID) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Invalid session id, unable to close, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -529,9 +570,11 @@ tf_session_close_session(struct tf *tfp, fid); if (!client) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Client not part of the session, unable to close, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -553,10 +596,12 @@ tf_session_close_session(struct tf *tfp, */ rc = tf_session_client_destroy(tfp, &scdparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to unregister Client %d, rc:%s\n", client->session_client_id.id, - strerror(-rc)); + errmsg); return rc; } @@ -574,9 +619,11 @@ tf_session_close_session(struct tf *tfp, rc = tf_session_get_device(tfs, &tfd); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Device lookup failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -584,9 +631,11 @@ tf_session_close_session(struct tf *tfp, rc = tf_session_get_fw_session_id(tfp, &fw_session_id); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Unable to lookup FW id, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -594,17 +643,21 @@ tf_session_close_session(struct tf *tfp, rc = tf_dev_unbind(tfp, tfd); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Device unbind failed, rc:%s\n", - strerror(-rc)); + errmsg); } rc = tf_msg_session_close(tfp, fw_session_id, mailbox); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "FW Session close failed, rc:%s\n", - strerror(-rc)); + errmsg); } /* Final cleanup as we're last user of the session thus we @@ -652,13 +705,16 @@ tf_session_get_session_internal(struct tf *tfp, struct tf_session **tfs) { int rc = 0; + char errmsg[RTE_STRERR_BUFSIZE]; /* Skip using the check macro as we want to control the error msg */ if (tfp->session == NULL || tfp->session->core_data == NULL) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session not created, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -674,6 +730,7 @@ tf_session_get_session(struct tf *tfp, int rc; uint16_t fw_fid; bool supported = false; + char errmsg[RTE_STRERR_BUFSIZE]; rc = tf_session_get_session_internal(tfp, tfs); @@ -687,18 +744,22 @@ tf_session_get_session(struct tf *tfp, */ rc = tfp_get_fid(tfp, &fw_fid); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Internal FID lookup\n, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } supported = tf_session_is_fid_supported(*tfs, fw_fid); if (!supported) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG (ERR, "Ctrl channel not registered with session\n, rc:%s\n", - strerror(-rc)); + errmsg); return -EINVAL; } @@ -804,21 +865,26 @@ tf_session_get_fw_session_id(struct tf *tfp, { int rc; struct tf_session *tfs = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; /* Skip using the check macro as we want to control the error msg */ if (tfp->session == NULL) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session not created, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (fw_session_id == NULL) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Invalid Argument(s), rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -837,20 +903,25 @@ tf_session_get_session_id(struct tf *tfp, { int rc; struct tf_session *tfs = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; if (tfp->session == NULL) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session not created, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (session_id == NULL) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Invalid Argument(s), rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -1147,29 +1218,36 @@ tf_session_set_hotup_state(struct tf *tfp, { int rc = 0; struct tf_session *tfs = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session lookup failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (!tf_session_is_shared_session(tfs)) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Only shared session able to set state, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_msg_session_set_hotup_state(tfp, parms->state); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Set session hot upgrade state failed, rc:%s\n", - strerror(-rc)); + errmsg); } return rc; @@ -1181,29 +1259,36 @@ tf_session_get_hotup_state(struct tf *tfp, { int rc = 0; struct tf_session *tfs = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; rc = tf_session_get_session(tfp, &tfs); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Session lookup failed, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (!tf_session_is_shared_session(tfs)) { rc = -EINVAL; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Only shared session able to get state, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } rc = tf_msg_session_get_hotup_state(tfp, &parms->state, &parms->ref_cnt); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Get session hot upgrade state failed, rc:%s\n", - strerror(-rc)); + errmsg); } return rc; diff --git a/drivers/net/bnxt/tf_core/tf_sram_mgr.c b/drivers/net/bnxt/tf_core/tf_sram_mgr.c index 87e8882fed..14e8a77746 100644 --- a/drivers/net/bnxt/tf_core/tf_sram_mgr.c +++ b/drivers/net/bnxt/tf_core/tf_sram_mgr.c @@ -484,6 +484,7 @@ static struct tf_sram_block { struct tf_sram_block *block; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; int rc; cparms.nitems = 1; @@ -492,9 +493,11 @@ static struct tf_sram_block rc = tfp_calloc(&cparms); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to allocate block, rc:%s\n", - strerror(-rc)); + errmsg); return NULL; } block = (struct tf_sram_block *)cparms.mem_va; @@ -577,6 +580,7 @@ tf_sram_mgr_bind(void **sram_handle) int rc = 0; struct tf_sram *sram; struct tfp_calloc_parms cparms; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS1(sram_handle); @@ -586,9 +590,11 @@ tf_sram_mgr_bind(void **sram_handle) rc = tfp_calloc(&cparms); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to allocate SRAM mgmt data, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } sram = (struct tf_sram *)cparms.mem_va; @@ -602,6 +608,7 @@ tf_sram_mgr_unbind(void *sram_handle) int rc = 0; struct tf_sram *sram; enum tf_sram_bank_id bank_id; + char errmsg[RTE_STRERR_BUFSIZE]; enum tf_sram_slice_size slice_size; enum tf_dir dir; struct tf_sram_slice_list *slice_list; @@ -626,9 +633,12 @@ tf_sram_mgr_unbind(void *sram_handle) bank_id); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), + "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "No SRAM slice list, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (tf_sram_get_block_cnt(slice_list)) @@ -653,6 +663,7 @@ int tf_sram_mgr_alloc(void *sram_handle, uint16_t block_id, slice_offset = 0; uint32_t index, next_index; struct tf_sram_block *block; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_rm_allocate_parms aparms = { 0 }; struct tf_rm_free_parms fparms = { 0 }; bool block_is_full; @@ -668,9 +679,11 @@ int tf_sram_mgr_alloc(void *sram_handle, parms->dir, parms->bank_id); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "No SRAM slice list, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -746,6 +759,7 @@ tf_sram_mgr_free(void *sram_handle, struct tf_sram_block *block; bool block_is_empty; struct tf_rm_free_parms fparms = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(sram_handle, parms); @@ -757,9 +771,11 @@ tf_sram_mgr_free(void *sram_handle, parms->dir, parms->bank_id); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "No SRAM slice list, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -781,7 +797,9 @@ tf_sram_mgr_free(void *sram_handle, rc = tf_sram_free_slice(parms->slice_size, slice_offset, block, &block_is_empty); if (rc) { - TFP_DRV_LOG(ERR, "Error freeing slice (%s)\n", strerror(-rc)); + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); + TFP_DRV_LOG(ERR, "Error freeing slice (%s)\n", errmsg); return rc; } #if (STATS_CLEAR_ON_READ_SUPPORT == 0) @@ -801,11 +819,13 @@ tf_sram_mgr_free(void *sram_handle, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->tbl_type), - strerror(-rc)); + errmsg); return rc; } /* Clear the counter @@ -817,11 +837,13 @@ tf_sram_mgr_free(void *sram_handle, data, parms->sram_offset); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Set failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->tbl_type), - strerror(-rc)); + errmsg); return rc; } } @@ -835,15 +857,19 @@ tf_sram_mgr_free(void *sram_handle, rc = tf_rm_free(&fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Free block_id(%d) failed error(%s)\n", - block_id, strerror(-rc)); + block_id, errmsg); } fparms.index = block_id + 1; rc = tf_rm_free(&fparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Free next block_id(%d) failed error(%s)\n", - block_id + 1, strerror(-rc)); + block_id + 1, errmsg); } /* Free local entry regardless */ tf_sram_free_block(slice_list, block); @@ -921,6 +947,7 @@ int tf_sram_mgr_is_allocated(void *sram_handle, { int rc = 0; struct tf_sram *sram; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_sram_slice_list *slice_list; uint16_t block_id, slice_offset; struct tf_sram_block *block; @@ -935,9 +962,11 @@ int tf_sram_mgr_is_allocated(void *sram_handle, parms->dir, parms->bank_id); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "No SRAM slice list, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c index f5f3889934..d82a73ee20 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl.c +++ b/drivers/net/bnxt/tf_core/tf_tbl.c @@ -31,6 +31,7 @@ tf_tbl_bind(struct tf *tfp, struct tbl_rm_db *tbl_db; struct tfp_calloc_parms cparms; struct tf_session *tfs; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -44,8 +45,10 @@ tf_tbl_bind(struct tf *tfp, cparms.size = sizeof(struct tbl_rm_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "tbl_rm_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -126,6 +129,7 @@ tf_tbl_alloc(struct tf *tfp __rte_unused, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -141,9 +145,11 @@ tf_tbl_alloc(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tbl_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; @@ -178,6 +184,7 @@ tf_tbl_free(struct tf *tfp __rte_unused, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -193,9 +200,11 @@ tf_tbl_free(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; @@ -230,11 +239,13 @@ tf_tbl_free(struct tf *tfp __rte_unused, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } /* Clear the counter @@ -246,11 +257,13 @@ tf_tbl_free(struct tf *tfp __rte_unused, data, parms->idx); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Set failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } } @@ -285,6 +298,7 @@ tf_tbl_set(struct tf *tfp, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -300,9 +314,11 @@ tf_tbl_set(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; @@ -337,11 +353,13 @@ tf_tbl_set(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -352,11 +370,13 @@ tf_tbl_set(struct tf *tfp, parms->data, parms->idx); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Set failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -376,6 +396,7 @@ tf_tbl_get(struct tf *tfp, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -391,9 +412,11 @@ tf_tbl_get(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; @@ -428,11 +451,13 @@ tf_tbl_get(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -445,11 +470,13 @@ tf_tbl_get(struct tf *tfp, parms->idx, false); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Get failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -468,6 +495,7 @@ tf_tbl_bulk_get(struct tf *tfp, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -483,9 +511,11 @@ tf_tbl_bulk_get(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; @@ -513,11 +543,13 @@ tf_tbl_bulk_get(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -531,11 +563,13 @@ tf_tbl_bulk_get(struct tf *tfp, parms->physical_mem_addr, false); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Bulk get failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); } return rc; diff --git a/drivers/net/bnxt/tf_core/tf_tbl_sram.c b/drivers/net/bnxt/tf_core/tf_tbl_sram.c index 3a6f1c68c7..baef72d81c 100644 --- a/drivers/net/bnxt/tf_core/tf_tbl_sram.c +++ b/drivers/net/bnxt/tf_core/tf_tbl_sram.c @@ -101,6 +101,7 @@ static int tf_tbl_sram_get_info(struct tf_tbl_sram_get_info_parms *parms) int rc = 0; uint16_t hcapi_type; uint16_t slices; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_rm_get_hcapi_parms hparms; struct tf_rm_get_slices_parms sparms; @@ -110,11 +111,13 @@ static int tf_tbl_sram_get_info(struct tf_tbl_sram_get_info_parms *parms) rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to get hcapi_type %s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->tbl_type), - strerror(-rc)); + errmsg); return rc; } parms->bank_id = tf_tbl_sram_hcapi_2_bank[hcapi_type]; @@ -125,11 +128,13 @@ static int tf_tbl_sram_get_info(struct tf_tbl_sram_get_info_parms *parms) rc = tf_rm_get_slices(&sparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Failed to get slice cnt %s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->tbl_type), - strerror(-rc)); + errmsg); return rc; } if (slices) @@ -161,14 +166,17 @@ tf_tbl_sram_unbind(struct tf *tfp __rte_unused) { int rc = 0; void *sram_handle = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS1(tfp); rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } if (sram_handle) @@ -187,6 +195,7 @@ tf_tbl_sram_alloc(struct tf *tfp, uint16_t idx; struct tf_session *tfs; struct tf_dev_info *dev; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_sram_get_info_parms iparms = { 0 }; struct tf_sram_mgr_alloc_parms aparms = { 0 }; struct tbl_rm_db *tbl_db; @@ -202,9 +211,11 @@ tf_tbl_sram_alloc(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tbl_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -212,9 +223,11 @@ tf_tbl_sram_alloc(struct tf *tfp, rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -273,6 +286,7 @@ tf_tbl_sram_free(struct tf *tfp __rte_unused, struct tf_dev_info *dev; struct tbl_rm_db *tbl_db; void *tbl_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; struct tf_tbl_sram_get_info_parms iparms = { 0 }; struct tf_sram_mgr_free_parms fparms = { 0 }; struct tf_sram_mgr_is_allocated_parms aparms = { 0 }; @@ -288,18 +302,22 @@ tf_tbl_sram_free(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -340,12 +358,14 @@ tf_tbl_sram_free(struct tf *tfp __rte_unused, rc = tf_sram_mgr_is_allocated(sram_handle, &aparms); if (rc || !allocated) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Free of invalid entry:%s idx(0x%x):(%s)\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); rc = -ENOMEM; return rc; } @@ -405,6 +425,7 @@ tf_tbl_sram_set(struct tf *tfp, struct tf_rm_is_allocated_parms raparms = { 0 }; void *sram_handle = NULL; uint16_t base = 0, shift = 0; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -415,18 +436,22 @@ tf_tbl_sram_set(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -484,12 +509,14 @@ tf_tbl_sram_set(struct tf *tfp, aparms.is_allocated = &allocated; rc = tf_sram_mgr_is_allocated(sram_handle, &aparms); if (rc || !allocated) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Entry not allocated:%s idx(0x%x):(%s)\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); rc = -ENOMEM; return rc; } @@ -500,11 +527,13 @@ tf_tbl_sram_set(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -515,11 +544,13 @@ tf_tbl_sram_set(struct tf *tfp, parms->data, parms->idx); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Set failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } return rc; @@ -541,6 +572,7 @@ tf_tbl_sram_get(struct tf *tfp, struct tf_sram_mgr_is_allocated_parms aparms = { 0 }; void *sram_handle = NULL; bool clear_on_read = false; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS3(tfp, parms, parms->data); @@ -551,18 +583,22 @@ tf_tbl_sram_get(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -587,12 +623,14 @@ tf_tbl_sram_get(struct tf *tfp, rc = tf_sram_mgr_is_allocated(sram_handle, &aparms); if (rc || !allocated) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Entry not allocated:%s idx(0x%x):(%s)\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); rc = -ENOMEM; return rc; } @@ -603,11 +641,13 @@ tf_tbl_sram_get(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } if (parms->type == TF_TBL_TYPE_ACT_STATS_64) @@ -622,11 +662,13 @@ tf_tbl_sram_get(struct tf *tfp, parms->idx, clear_on_read); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Get failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } return rc; @@ -649,6 +691,7 @@ tf_tbl_sram_bulk_get(struct tf *tfp, bool allocated = false; void *sram_handle = NULL; bool clear_on_read = false; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -659,18 +702,22 @@ tf_tbl_sram_bulk_get(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tbl_db = (struct tbl_rm_db *)tbl_db_ptr; rc = tf_session_get_sram_db(tfp, &sram_handle); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get sram_handle from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -698,12 +745,14 @@ tf_tbl_sram_bulk_get(struct tf *tfp, aparms.is_allocated = &allocated; rc = tf_sram_mgr_is_allocated(sram_handle, &aparms); if (rc || !allocated) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Entry not allocated:%s starting_idx(%d):(%s)\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), parms->starting_idx, - strerror(-rc)); + errmsg); rc = -ENOMEM; return rc; } @@ -711,12 +760,14 @@ tf_tbl_sram_bulk_get(struct tf *tfp, aparms.sram_offset = idx; rc = tf_sram_mgr_is_allocated(sram_handle, &aparms); if (rc || !allocated) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Entry not allocated:%s last_idx(0x%x):(%s)\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), idx, - strerror(-rc)); + errmsg); rc = -ENOMEM; return rc; } @@ -726,11 +777,13 @@ tf_tbl_sram_bulk_get(struct tf *tfp, hparms.hcapi_type = &hcapi_type; rc = tf_rm_get_hcapi_type(&hparms); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Failed type lookup, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); return rc; } @@ -747,11 +800,13 @@ tf_tbl_sram_bulk_get(struct tf *tfp, parms->physical_mem_addr, clear_on_read); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s, Bulk get failed, type:%s, rc:%s\n", tf_dir_2_str(parms->dir), tf_tbl_type_2_str(parms->type), - strerror(-rc)); + errmsg); } return rc; } diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c index 9e0671d47b..4e97556bc5 100644 --- a/drivers/net/bnxt/tf_core/tf_tcam.c +++ b/drivers/net/bnxt/tf_core/tf_tcam.c @@ -40,6 +40,7 @@ tf_tcam_bind(struct tf *tfp, uint32_t rx_supported; uint32_t tx_supported; bool no_req = true; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -55,9 +56,11 @@ tf_tcam_bind(struct tf *tfp, if (dev->ops->tf_dev_get_tcam_slice_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Operation not supported, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } @@ -90,8 +93,10 @@ tf_tcam_bind(struct tf *tfp, cparms.size = sizeof(struct tcam_rm_db); cparms.alignment = 0; if (tfp_calloc(&cparms) != 0) { + if (strerror_r(ENOMEM, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", ENOMEM); TFP_DRV_LOG(ERR, "tcam_rm_db alloc error %s\n", - strerror(ENOMEM)); + errmsg); return -ENOMEM; } @@ -283,6 +288,7 @@ tf_tcam_alloc(struct tf *tfp, uint32_t index; struct tcam_rm_db *tcam_db; void *tcam_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -298,10 +304,12 @@ tf_tcam_alloc(struct tf *tfp, if (dev->ops->tf_dev_get_tcam_slice_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -318,9 +326,11 @@ tf_tcam_alloc(struct tf *tfp, return tf_tcam_mgr_alloc_msg(tfp, dev, parms); rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get tcam_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tcam_db = (struct tcam_rm_db *)tcam_db_ptr; @@ -367,6 +377,7 @@ tf_tcam_free(struct tf *tfp, int i; struct tcam_rm_db *tcam_db; void *tcam_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -382,10 +393,12 @@ tf_tcam_free(struct tf *tfp, if (dev->ops->tf_dev_get_tcam_slice_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -415,9 +428,11 @@ tf_tcam_free(struct tf *tfp, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tcam_db = (struct tcam_rm_db *)tcam_db_ptr; @@ -472,12 +487,14 @@ tf_tcam_free(struct tf *tfp, rc = tf_msg_tcam_entry_free(tfp, dev, parms); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed, rc:%s\n", tf_dir_2_str(parms->dir), tf_tcam_tbl_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); return rc; } @@ -497,6 +514,7 @@ tf_tcam_set(struct tf *tfp __rte_unused, int allocated = 0; struct tcam_rm_db *tcam_db; void *tcam_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -512,10 +530,12 @@ tf_tcam_set(struct tf *tfp __rte_unused, if (dev->ops->tf_dev_get_tcam_slice_info == NULL) { rc = -EOPNOTSUPP; + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: Operation not supported, rc:%s\n", tf_dir_2_str(parms->dir), - strerror(-rc)); + errmsg); return rc; } @@ -533,9 +553,11 @@ tf_tcam_set(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tcam_db = (struct tcam_rm_db *)tcam_db_ptr; @@ -574,12 +596,14 @@ tf_tcam_set(struct tf *tfp __rte_unused, rc = tf_msg_tcam_entry_set(tfp, dev, parms); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: %s: Entry %d set failed, rc:%s", tf_dir_2_str(parms->dir), tf_tcam_tbl_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); return rc; } return 0; @@ -597,6 +621,7 @@ tf_tcam_get(struct tf *tfp __rte_unused, int allocated = 0; struct tcam_rm_db *tcam_db; void *tcam_db_ptr = NULL; + char errmsg[RTE_STRERR_BUFSIZE]; TF_CHECK_PARMS2(tfp, parms); @@ -616,9 +641,11 @@ tf_tcam_get(struct tf *tfp __rte_unused, rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr); if (rc) { + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "Failed to get em_ext_db from session, rc:%s\n", - strerror(-rc)); + errmsg); return rc; } tcam_db = (struct tcam_rm_db *)tcam_db_ptr; @@ -657,12 +684,14 @@ tf_tcam_get(struct tf *tfp __rte_unused, rc = tf_msg_tcam_entry_get(tfp, dev, parms); if (rc) { /* Log error */ + if (strerror_r(-rc, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -rc); TFP_DRV_LOG(ERR, "%s: %s: Entry %d set failed, rc:%s", tf_dir_2_str(parms->dir), tf_tcam_tbl_2_str(parms->type), parms->idx, - strerror(-rc)); + errmsg); return rc; } -- 2.33.0