It may be useful to see why a remote system has returned an error for a
PMC command, so add some code to print the error code and the string
interpretation of it.

Signed-off-by: Vladimir Oltean <olte...@gmail.com>
---
 pmc_agent.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/pmc_agent.c b/pmc_agent.c
index 68300f4303f6..91bdd34eebb6 100644
--- a/pmc_agent.c
+++ b/pmc_agent.c
@@ -102,6 +102,36 @@ static int get_mgt_err_id(struct ptp_message *msg)
        return mgt->id;
 }
 
+static int get_mgt_err_code(struct ptp_message *msg)
+{
+       struct management_error_status *mgt;
+
+       mgt = (struct management_error_status *)msg->management.suffix;
+       return mgt->error;
+}
+
+static const char *mgt_err_code_to_string(int mgt_error)
+{
+       switch (mgt_error) {
+       case MID_RESPONSE_TOO_BIG:
+               return "response too big";
+       case MID_NO_SUCH_ID:
+               return "no such ID";
+       case MID_WRONG_LENGTH:
+               return "wrong length";
+       case MID_WRONG_VALUE:
+               return "wrong value";
+       case MID_NOT_SETABLE:
+               return "not settable";
+       case MID_NOT_SUPPORTED:
+               return "not supported";
+       case MID_GENERAL_ERROR:
+               return "general error";
+       default:
+               return "unknown";
+       }
+}
+
 #define RUN_PMC_OKAY    1
 #define RUN_PMC_TMO     0
 #define RUN_PMC_NODEV  -1
@@ -181,6 +211,10 @@ static int run_pmc(struct pmc_agent *node, int timeout, 
int ds_id,
 
                res = is_msg_mgt(*msg);
                if (res < 0 && get_mgt_err_id(*msg) == ds_id) {
+                       int err_code = get_mgt_err_code(*msg);
+
+                       pr_err("PMC got management error code %d (%s)",
+                              err_code, mgt_err_code_to_string(err_code));
                        node->pmc_ds_requested = 0;
                        return RUN_PMC_NODEV;
                }
-- 
2.25.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to