The API receives a priority and looks for the TC it is mapped to in the
operational DCBX configuration.

Signed-off-by: Denis Bolotin <denis.bolo...@cavium.com>
Signed-off-by: Ariel Elior <ariel.el...@cavium.com>
---
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 27 +++++++++++++++++++++++++++
 drivers/net/ethernet/qlogic/qed/qed_dcbx.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c 
b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 12b4c2a..00891cc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -1277,6 +1277,33 @@ int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn,
        return 0;
 }
 
+int qed_dcbx_get_priority_tc(struct qed_hwfn *p_hwfn, u8 pri, u8 *p_tc)
+{
+       struct qed_dcbx_get *dcbx_info;
+       int rc;
+
+       if (pri >= QED_MAX_PFC_PRIORITIES) {
+               DP_ERR(p_hwfn, "Invalid priority %d\n", pri);
+               return -EINVAL;
+       }
+
+       dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL);
+       if (!dcbx_info)
+               return -ENOMEM;
+
+       rc = qed_dcbx_query_params(p_hwfn, dcbx_info,
+                                  QED_DCBX_OPERATIONAL_MIB);
+       if (rc) {
+               kfree(dcbx_info);
+               return rc;
+       }
+
+       *p_tc = dcbx_info->operational.params.ets_pri_tc_tbl[pri];
+       kfree(dcbx_info);
+
+       return 0;
+}
+
 static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
                                               enum qed_mib_read_type type)
 {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.h 
b/drivers/net/ethernet/qlogic/qed/qed_dcbx.h
index 5feb90e..9425d55 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.h
@@ -111,6 +111,8 @@ struct qed_dcbx_mib_meta_data {
 
 int qed_dcbx_config_params(struct qed_hwfn *,
                           struct qed_ptt *, struct qed_dcbx_set *, bool);
+
+int qed_dcbx_get_priority_tc(struct qed_hwfn *p_hwfn, u8 pri, u8 *p_tc);
 #endif
 
 /* QED local interface routines */
-- 
1.8.3.1

Reply via email to