=======================================================
* rawdev: Added a structure size parameter to the functions
+ ``rte_rawdev_queue_setup()``, ``rte_rawdev_queue_conf_get()``,
``rte_rawdev_info_get()`` and ``rte_rawdev_configure()``,
allowing limited driver type-checking and ABI compatibility.
static void
ntb_queue_conf_get(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
struct ntb_queue_conf *q_conf = queue_conf;
struct ntb_hw *hw = dev->dev_private;
+ if (conf_size != sizeof(*q_conf))
+ return;
+
q_conf->tx_free_thresh = hw->tx_queues[queue_id]->tx_free_thresh;
q_conf->nb_desc = hw->rx_queues[queue_id]->nb_rx_desc;
q_conf->rx_mp = hw->rx_queues[queue_id]->mpool;
static int
ntb_rxq_setup(struct rte_rawdev *dev,
uint16_t qp_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
struct ntb_queue_conf *rxq_conf = queue_conf;
struct ntb_hw *hw = dev->dev_private;
struct ntb_rx_queue *rxq;
+ if (conf_size != sizeof(*rxq_conf))
+ return -EINVAL;
+
/* Allocate the rx queue data structure */
rxq = rte_zmalloc_socket("ntb rx queue",
sizeof(struct ntb_rx_queue),
static int
ntb_txq_setup(struct rte_rawdev *dev,
uint16_t qp_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
struct ntb_queue_conf *txq_conf = queue_conf;
struct ntb_hw *hw = dev->dev_private;
struct ntb_tx_queue *txq;
uint16_t i, prev;
+ if (conf_size != sizeof(*txq_conf))
+ return -EINVAL;
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("ntb tx queue",
sizeof(struct ntb_tx_queue),
static int
ntb_queue_setup(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
struct ntb_hw *hw = dev->dev_private;
int ret;
if (queue_id >= hw->queue_pairs)
return -EINVAL;
- ret = ntb_txq_setup(dev, queue_id, queue_conf);
+ ret = ntb_txq_setup(dev, queue_id, queue_conf, conf_size);
if (ret < 0)
return ret;
- ret = ntb_rxq_setup(dev, queue_id, queue_conf);
+ ret = ntb_rxq_setup(dev, queue_id, queue_conf, conf_size);
return ret;
}
static void skeleton_rawdev_queue_def_conf(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
struct skeleton_rawdev *skeldev;
struct skeleton_rawdev_queue *skelq;
SKELETON_PMD_FUNC_TRACE();
- if (!dev || !queue_conf)
+ if (!dev || !queue_conf ||
+ conf_size != sizeof(struct skeleton_rawdev_queue))
return;
skeldev = skeleton_rawdev_get_priv(dev);
static int skeleton_rawdev_queue_setup(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t conf_size)
{
int ret = 0;
struct skeleton_rawdev *skeldev;
SKELETON_PMD_FUNC_TRACE();
- if (!dev || !queue_conf)
+ if (!dev || !queue_conf ||
+ conf_size != sizeof(struct skeleton_rawdev_queue))
return -EINVAL;
skeldev = skeleton_rawdev_get_priv(dev);
* depth = DEF_DEPTH
*/
for (i = 0; i < rdev_conf_get.num_queues; i++) {
- rte_rawdev_queue_conf_get(test_dev_id, i, &q);
+ rte_rawdev_queue_conf_get(test_dev_id, i, &q, sizeof(q));
RTE_TEST_ASSERT_EQUAL(q.depth, SKELETON_QUEUE_DEF_DEPTH,
"Invalid default depth of queue (%d)",
q.depth);
/* Modify the queue depth for Queue 0 and attach it */
qset.depth = 15;
qset.state = SKELETON_QUEUE_ATTACH;
- ret = rte_rawdev_queue_setup(test_dev_id, 0, &qset);
+ ret = rte_rawdev_queue_setup(test_dev_id, 0, &qset, sizeof(qset));
RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup queue (%d)", ret);
/* Now, fetching the queue 0 should show depth as 15 */
- ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget);
+ ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget, sizeof(qget));
RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get queue config (%d)", ret);
RTE_TEST_ASSERT_EQUAL(qset.depth, qget.depth,
RTE_TEST_ASSERT_SUCCESS(ret, "Failed to release queue 0; (%d)", ret);
/* Now, fetching the queue 0 should show depth as default */
- ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget);
+ ret = rte_rawdev_queue_conf_get(test_dev_id, 0, &qget, sizeof(qget));
RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get queue config (%d)", ret);
RTE_TEST_ASSERT_EQUAL(qget.depth, SKELETON_QUEUE_DEF_DEPTH,
ntb_q_conf.rx_mp = mbuf_pool;
for (i = 0; i < num_queues; i++) {
/* Setup rawdev queue */
- ret = rte_rawdev_queue_setup(dev_id, i, &ntb_q_conf);
+ ret = rte_rawdev_queue_setup(dev_id, i, &ntb_q_conf,
+ sizeof(ntb_q_conf));
if (ret < 0)
rte_exit(EXIT_FAILURE,
"Failed to setup ntb queue %u.\n", i);
int
rte_rawdev_queue_conf_get(uint16_t dev_id,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size)
{
struct rte_rawdev *dev;
dev = &rte_rawdevs[dev_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_def_conf, -ENOTSUP);
- (*dev->dev_ops->queue_def_conf)(dev, queue_id, queue_conf);
+ (*dev->dev_ops->queue_def_conf)(dev, queue_id, queue_conf,
+ queue_conf_size);
return 0;
}
int
rte_rawdev_queue_setup(uint16_t dev_id,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf)
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size)
{
struct rte_rawdev *dev;
dev = &rte_rawdevs[dev_id];
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_setup, -ENOTSUP);
- return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf);
+ return (*dev->dev_ops->queue_setup)(dev, queue_id, queue_conf,
+ queue_conf_size);
}
int
* previously supplied to rte_rawdev_configure().
* @param[out] queue_conf
* The pointer to the default raw queue configuration data.
+ * @param queue_conf_size
+ * The size of the structure pointed to by queue_conf
* @return
* - 0: Success, driver updates the default raw queue configuration data.
* - <0: Error code returned by the driver info get function.
int
rte_rawdev_queue_conf_get(uint16_t dev_id,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf);
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size);
/**
* Allocate and set up a raw queue for a raw device.
* @param queue_conf
* The pointer to the configuration data to be used for the raw queue.
* NULL value is allowed, in which case default configuration used.
+ * @param queue_conf_size
+ * The size of the structure pointed to by queue_conf
*
* @see rte_rawdev_queue_conf_get()
*
int
rte_rawdev_queue_setup(uint16_t dev_id,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf);
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size);
/**
* Release and deallocate a raw queue from a raw device.
*/
typedef void (*rawdev_queue_conf_get_t)(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf);
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size);
/**
* Setup an raw queue.
*/
typedef int (*rawdev_queue_setup_t)(struct rte_rawdev *dev,
uint16_t queue_id,
- rte_rawdev_obj_t queue_conf);
+ rte_rawdev_obj_t queue_conf,
+ size_t queue_conf_size);
/**
* Release resources allocated by given raw queue.