net/iavf: fix VF to PF command failure handling
authorAlvin Zhang <alvinx.zhang@intel.com>
Sun, 25 Apr 2021 07:39:34 +0000 (15:39 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Mon, 26 Apr 2021 04:44:45 +0000 (06:44 +0200)
When the command sent by VF to PF fails, iavf may need to run
different code paths according to the specific reason of the
failure (not supported or other reasons).

This patch adds support of identifying PF return error type.

Fixes: 22b123a36d07 ("net/avf: initialize PMD")
Cc: stable@dpdk.org
Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/iavf/iavf.h
drivers/net/iavf/iavf_vchnl.c

index 1e73f01..4f5811a 100644 (file)
@@ -144,7 +144,7 @@ struct iavf_info {
        uint64_t supported_rxdid;
        uint8_t *proto_xtr; /* proto xtr type for all queues */
        volatile enum virtchnl_ops pend_cmd; /* pending command not finished */
-       uint32_t cmd_retval; /* return value of the cmd response from PF */
+       int cmd_retval; /* return value of the cmd response from PF */
        uint8_t *aq_resp; /* buffer to store the adminq response from PF */
 
        /* Event from pf */
@@ -264,7 +264,7 @@ struct iavf_cmd_info {
  * _atomic_set_cmd successfully.
  */
 static inline void
-_notify_cmd(struct iavf_info *vf, uint32_t msg_ret)
+_notify_cmd(struct iavf_info *vf, int msg_ret)
 {
        vf->cmd_retval = msg_ret;
        rte_wmb();
index b0fbe15..0026120 100644 (file)
@@ -228,13 +228,19 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)
                        rte_delay_ms(ASQ_DELAY_MS);
                        /* If don't read msg or read sys event, continue */
                } while (i++ < MAX_TRY_TIMES);
-               /* If there's no response is received, clear command */
-               if (i >= MAX_TRY_TIMES  ||
-                   vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
-                       err = -1;
-                       PMD_DRV_LOG(ERR, "No response or return failure (%d)"
-                                   " for cmd %d", vf->cmd_retval, args->ops);
+
+               if (i >= MAX_TRY_TIMES) {
+                       PMD_DRV_LOG(ERR, "No response for cmd %d", args->ops);
                        _clear_cmd(vf);
+                       err = -EIO;
+               } else if (vf->cmd_retval ==
+                          VIRTCHNL_STATUS_ERR_NOT_SUPPORTED) {
+                       PMD_DRV_LOG(ERR, "Cmd %d not supported", args->ops);
+                       err = -ENOTSUP;
+               } else if (vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
+                       PMD_DRV_LOG(ERR, "Return failure %d for cmd %d",
+                                   vf->cmd_retval, args->ops);
+                       err = -EINVAL;
                }
                break;
        }