]> git.droids-corp.org - dpdk.git/commitdiff
rawdev: allow drivers to return error from info query
authorBruce Richardson <bruce.richardson@intel.com>
Thu, 10 Sep 2020 14:36:04 +0000 (15:36 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 11 Sep 2020 09:50:54 +0000 (11:50 +0200)
Since we now allow some parameter checking inside the driver info_get()
functions, it makes sense to allow error return from those functions to the
caller. Therefore we change the driver callback return type from void to
int.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
doc/guides/rel_notes/release_20_11.rst
drivers/raw/ifpga/ifpga_rawdev.c
drivers/raw/ioat/ioat_rawdev.c
drivers/raw/ntb/ntb.c
drivers/raw/skeleton/skeleton_rawdev.c
lib/librte_rawdev/rte_rawdev.c
lib/librte_rawdev/rte_rawdev_pmd.h

index a931dc0bff84d0833d19ca80f09b4bc46d4638e2..6431efe56b56ac146f03aee51cc1c58935c5da0e 100644 (file)
@@ -88,6 +88,9 @@ API Changes
   ``rte_rawdev_info_get()``,
   allowing limited driver type-checking and ABI compatibility.
 
+* rawdev: Changed the return type of the function ``rte_dev_info_get()``
+  from ``void`` to ``int`` allowing the return of error codes from drivers.
+
 
 ABI Changes
 -----------
index 47cfa38778d122872a70319b6456afd35b57591b..32a2b96c90f6dc3a857ba37c351687c21de8fdf9 100644 (file)
@@ -603,7 +603,7 @@ ifpga_fill_afu_dev(struct opae_accelerator *acc,
        return 0;
 }
 
-static void
+static int
 ifpga_rawdev_info_get(struct rte_rawdev *dev,
                      rte_rawdev_obj_t dev_info,
                      size_t dev_info_size)
@@ -620,12 +620,12 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
 
        if (!dev_info || dev_info_size != sizeof(*afu_dev)) {
                IFPGA_RAWDEV_PMD_ERR("Invalid request");
-               return;
+               return -EINVAL;
        }
 
        adapter = ifpga_rawdev_get_priv(dev);
        if (!adapter)
-               return;
+               return -ENOENT;
 
        afu_dev = dev_info;
        afu_dev->rawdev = dev;
@@ -637,7 +637,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
 
                if (ifpga_fill_afu_dev(acc, afu_dev)) {
                        IFPGA_RAWDEV_PMD_ERR("cannot get info\n");
-                       return;
+                       return -ENOENT;
                }
        }
 
@@ -647,21 +647,21 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
                /* get LineSide BAR Index */
                if (opae_manager_get_eth_group_region_info(mgr, 0,
                        &opae_lside_eth_info)) {
-                       return;
+                       return -ENOENT;
                }
                lside_bar_idx = opae_lside_eth_info.mem_idx;
 
                /* get NICSide BAR Index */
                if (opae_manager_get_eth_group_region_info(mgr, 1,
                        &opae_nside_eth_info)) {
-                       return;
+                       return -ENOENT;
                }
                nside_bar_idx = opae_nside_eth_info.mem_idx;
 
                if (lside_bar_idx >= PCI_MAX_RESOURCE ||
                        nside_bar_idx >= PCI_MAX_RESOURCE ||
                        lside_bar_idx == nside_bar_idx)
-                       return;
+                       return -ENOENT;
 
                /* fill LineSide BAR Index */
                afu_dev->mem_resource[lside_bar_idx].phys_addr =
@@ -679,6 +679,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev,
                afu_dev->mem_resource[nside_bar_idx].addr =
                        opae_nside_eth_info.addr;
        }
+       return 0;
 }
 
 static int
index a5c0452d7e8653e527e1b727507b78337f9c8131..e2fc7872638c0856f954334e7f72d44a1edb44c6 100644 (file)
@@ -110,15 +110,18 @@ ioat_dev_stop(struct rte_rawdev *dev)
        RTE_SET_USED(dev);
 }
 
-static void
+static int
 ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
                size_t dev_info_size)
 {
        struct rte_ioat_rawdev_config *cfg = dev_info;
        struct rte_ioat_rawdev *ioat = dev->dev_private;
 
-       if (cfg != NULL && dev_info_size == sizeof(*cfg))
-               cfg->ring_size = ioat->ring_size;
+       if (dev_info == NULL || dev_info_size != sizeof(*cfg))
+               return -EINVAL;
+
+       cfg->ring_size = ioat->ring_size;
+       return 0;
 }
 
 static const char * const xstat_names[] = {
index c890c43a32cf1617cbc8d76f905e8d9af5464bd6..ced5b6d6240c948792f010ffab3741b2473ddc38 100644 (file)
@@ -800,7 +800,7 @@ end_of_rx:
        return nb_rx;
 }
 
-static void
+static int
 ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
                size_t dev_info_size)
 {
@@ -809,7 +809,7 @@ ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
 
        if (dev_info_size != sizeof(*info)) {
                NTB_LOG(ERR, "Invalid size parameter to %s", __func__);
-               return;
+               return -EINVAL;
        }
 
        info->mw_cnt = hw->mw_cnt;
@@ -824,7 +824,7 @@ ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
 
        if (!hw->queue_size || !hw->queue_pairs) {
                NTB_LOG(ERR, "No queue size and queue num assigned.");
-               return;
+               return -EAGAIN;
        }
 
        hw->hdr_size_per_queue = RTE_ALIGN(sizeof(struct ntb_header) +
@@ -832,6 +832,8 @@ ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info,
                                hw->queue_size * sizeof(struct ntb_used),
                                RTE_CACHE_LINE_SIZE);
        info->ntb_hdr_size = hw->hdr_size_per_queue * hw->queue_pairs;
+
+       return 0;
 }
 
 static int
index dc05f3ecf851f015ce71ba824c202a4d2df48a5b..dce300c3587b4878d91c5753543d8be39046ef27 100644 (file)
@@ -41,7 +41,7 @@ struct queue_buffers {
 static struct queue_buffers queue_buf[SKELETON_MAX_QUEUES] = {};
 static void clear_queue_bufs(int queue_id);
 
-static void skeleton_rawdev_info_get(struct rte_rawdev *dev,
+static int skeleton_rawdev_info_get(struct rte_rawdev *dev,
                                     rte_rawdev_obj_t dev_info,
                                     size_t dev_info_size)
 {
@@ -52,7 +52,7 @@ static void skeleton_rawdev_info_get(struct rte_rawdev *dev,
 
        if (!dev_info || dev_info_size != sizeof(*skeldev_conf)) {
                SKELETON_PMD_ERR("Invalid request");
-               return;
+               return -EINVAL;
        }
 
        skeldev = skeleton_rawdev_get_priv(dev);
@@ -63,6 +63,8 @@ static void skeleton_rawdev_info_get(struct rte_rawdev *dev,
        skeldev_conf->capabilities = skeldev->capabilities;
        skeldev_conf->device_state = skeldev->device_state;
        skeldev_conf->firmware_state = skeldev->fw.firmware_state;
+
+       return 0;
 }
 
 static int skeleton_rawdev_configure(const struct rte_rawdev *dev,
index a57689035678e600032f8a956f7fe89e2de4d9ce..bde33763eec73c77b1d45ce430b768749211287e 100644 (file)
@@ -82,6 +82,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info,
                size_t dev_private_size)
 {
        struct rte_rawdev *rawdev;
+       int ret = 0;
 
        RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
        RTE_FUNC_PTR_OR_ERR_RET(dev_info, -EINVAL);
@@ -90,7 +91,8 @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info,
 
        if (dev_info->dev_private != NULL) {
                RTE_FUNC_PTR_OR_ERR_RET(*rawdev->dev_ops->dev_info_get, -ENOTSUP);
-               (*rawdev->dev_ops->dev_info_get)(rawdev, dev_info->dev_private,
+               ret = (*rawdev->dev_ops->dev_info_get)(rawdev,
+                               dev_info->dev_private,
                                dev_private_size);
        }
 
@@ -98,7 +100,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info *dev_info,
        dev_info->device = rawdev->device;
        dev_info->socket_id = rawdev->socket_id;
 
-       return 0;
+       return ret;
 }
 
 int
index 0e72a92058be86cf6a4dbfdd0ce735d27779543a..89e46412a32e1cec02c09d2c5d4bc4bb51515c73 100644 (file)
@@ -142,9 +142,9 @@ rte_rawdev_pmd_is_valid_dev(uint8_t dev_id)
  *   The size of the structure pointed to by dev_info->dev_private
  *
  * @return
- *   Returns 0 on success
+ *   Returns 0 on success, negative error code on failure
  */
-typedef void (*rawdev_info_get_t)(struct rte_rawdev *dev,
+typedef int (*rawdev_info_get_t)(struct rte_rawdev *dev,
                                  rte_rawdev_obj_t dev_info,
                                  size_t dev_private_size);