net/mlx5: code cleanup in rx and tx files
cover net/mlx5: code cleanup in rx and tx files
During work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: add missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to static
drivers/net/mlx5/mlx5_rxq.c | 218 +++++++++++++++++++------------------------ drivers/net/mlx5/mlx5_rxtx.h | 20 ---- drivers/net/mlx5/mlx5_txq.c | 13 --- 3 files changed, 94 insertions(+), 157 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 net/mlx5: remove unused functions
Functions implemented but never called:mlx5_rxq_ibv_releasable()mlx5_rxq_cleanup()mlx5_txq_ibv_releasable()
Function declared but not implemented:rxq_alloc_mprq_buf()
This patch removes these functions from code and header file.
--- drivers/net/mlx5/mlx5_rxq.c | 31 ------------------------------- drivers/net/mlx5/mlx5_rxtx.h | 4 ---- drivers/net/mlx5/mlx5_txq.c | 13 ------------- 3 files changed, 48 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -31
@@ -353,24 +353,6 @@ }/** -* Clean up a RX queue. -* -* Destroy objects, free allocated memory and reset the structure for reuse. -* -* @param rxq_ctrl -* Pointer to RX queue structure. -*/ -void -mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl) -{ -DRV_LOG (DEBUG ,"port %u cleaning up Rx queue %u" , -PORT_ID (rxq_ctrl->priv), rxq_ctrl->rxq.idx); -if (rxq_ctrl->ibv) -mlx5_rxq_ibv_release (rxq_ctrl->ibv); -memset (rxq_ctrl,0 ,sizeof (*rxq_ctrl)); -} - -/** * Returns the per-queue supported offloads. * * @param dev
@@ -1116,19 +1098,6 @@ struct mlx5_rxq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param rxq_ibv -* Verbs Rx queue object. -*/ -int -mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -return (rte_atomic32_read (&rxq_ibv->refcnt) ==1 ); -} - -/** * Callback function to initialize mbufs for Multi-Packet RQ. */ static inline void
drivers/net/mlx5/mlx5_rxtx.h +0 -4
@@ -251,7 +251,6 @@ struct mlx5_txq_ctrl {int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);int mlx5_mprq_alloc_mp (struct rte_eth_dev *dev); -void mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl);int mlx5_rx_queue_setup (struct rte_eth_dev *dev,uint16_t idx,uint16_t desc,unsigned int socket,const struct rte_eth_rxconf *conf,struct rte_mempool *mp);
@@ -263,7 +262,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -int mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv);struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev);void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev);
@@ -276,7 +274,6 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -int rxq_alloc_mprq_buf (struct mlx5_rxq_ctrl *rxq_ctrl);struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n);
@@ -313,7 +310,6 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_txq_ibv *mlx5_txq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_txq_ibv *mlx5_txq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_ibv_release (struct mlx5_txq_ibv *txq_ibv); -int mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv);int mlx5_txq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
drivers/net/mlx5/mlx5_txq.c +0 -13
@@ -664,19 +664,6 @@ struct mlx5_txq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param txq_ibv -* Verbs Tx queue object. -*/ -int -mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv) -{ -assert (txq_ibv); -return (rte_atomic32_read (&txq_ibv->refcnt) ==1 ); -} - -/** * Verify the Verbs Tx queue list is empty * * @param dev
Signature · 1 line
1.8.3.1
PATCH 2/4 net/mlx5: add missing validation of null pointer
In reply to Dekel PeledFunction mlx5_rxq_ibv_release() is called in several places. Before each call except one, the input parameter is validated to make sure it is not null.
This patch adds the missing validation where it is missing.
--- drivers/net/mlx5/mlx5_rxq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_rxq.c +2 -1
@@ -602,7 +602,8 @@*/ rxq_data = (*priv->rxqs)[i]; rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -mlx5_rxq_ibv_release (rxq_ctrl->ibv); +if (rxq_ctrl->ibv) +mlx5_rxq_ibv_release (rxq_ctrl->ibv); } free:rte_intr_free_epoll_fd (intr_handle);
Signature · 1 line
1.8.3.1
PATCH 3/4 net/mlx5: fix description of function return value
In reply to Dekel PeledReturn value of function mlx5_rxq_releasable() was not described correctly in function description.
This patch updates the description to correctly describe the optional return values.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -1531,8 +1531,9 @@ struct mlx5_rxq_ctrl ** RX queue index. * * @return -* 1 if the queue can be released, negative errno otherwise and rte_errno is -* set. +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. */ int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx)
Signature · 1 line
1.8.3.1
PATCH 4/4 net/mlx5: move locally used functions to static
In reply to Dekel PeledMultiple functions were declared in header file mlx5_rxtx.h, inplemented in mlx5_rxq.c, and called only in mlx5_rxq.c.
This patch moves all these functions declarations into mlx5_rxq.c, as static functions.
Some functions implementation was copied higher in the file to precede the functions calls.
--- drivers/net/mlx5/mlx5_rxq.c | 185 +++++++++++++++++++++---------------------- drivers/net/mlx5/mlx5_rxtx.h | 16 ---- 2 files changed, 92 insertions(+), 109 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +92 -93
@@ -65,7 +65,7 @@* @return * 1 if supported, negative errno value if not. */ -inline int +static inline int mlx5_check_mprq_support (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -403,6 +403,33 @@ }/** +* Verify if the queue can be released. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* RX queue index. +* +* @return +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. +*/ +static int +mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (!(*priv->rxqs)[idx]) { + rte_errno =EINVAL ; +return -rte_errno; + } + rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); +return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); +} + +/** * * @param dev * Pointer to Ethernet device structure.
@@ -490,6 +517,63 @@ }/** +* Get an Rx queue Verbs object. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* Queue index in DPDK Rx queue array +* +* @return +* The Verbs object if it exists. +*/ +static struct mlx5_rxq_ibv * +mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (idx >= priv->rxqs_n) +return NULL ; +if (!rxq_data) +return NULL ; + rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); +if (rxq_ctrl->ibv) +rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); +return rxq_ctrl->ibv; +} + +/** +* Release an Rx verbs queue object. +* +* @param rxq_ibv +* Verbs Rx queue object. +* +* @return +* 1 while a reference on it exists, 0 when freed. +*/ +static int +mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) +{ +assert (rxq_ibv); +assert (rxq_ibv->wq); +assert (rxq_ibv->cq); +if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { +rxq_free_elts (rxq_ibv->rxq_ctrl); +claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); +claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); +if (rxq_ibv->channel) +claim_zero (mlx5_glue->destroy_comp_channel + (rxq_ibv->channel)); +LIST_REMOVE (rxq_ibv, next); +rte_free (rxq_ibv); +return 0 ; + } +return 1 ; +} + +/** * Allocate queue vector and fill epoll fd list for Rx interrupts. * * @param dev
@@ -1017,64 +1101,6 @@ struct mlx5_rxq_ibv * }/** -* Get an Rx queue Verbs object. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* Queue index in DPDK Rx queue array -* -* @return -* The Verbs object if it exists. -*/ -struct mlx5_rxq_ibv * -mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (idx >= priv->rxqs_n) -return NULL ; -if (!rxq_data) -return NULL ; - rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -if (rxq_ctrl->ibv) { -rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); - } -return rxq_ctrl->ibv; -} - -/** -* Release an Rx verbs queue object. -* -* @param rxq_ibv -* Verbs Rx queue object. -* -* @return -* 1 while a reference on it exists, 0 when freed. -*/ -int -mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -assert (rxq_ibv->wq); -assert (rxq_ibv->cq); -if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { -rxq_free_elts (rxq_ibv->rxq_ctrl); -claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); -claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); -if (rxq_ibv->channel) -claim_zero (mlx5_glue->destroy_comp_channel - (rxq_ibv->channel)); -LIST_REMOVE (rxq_ibv, next); -rte_free (rxq_ibv); -return 0 ; - } -return 1 ; -} - -/** * Verify the Verbs Rx queue list is empty * * @param dev
@@ -1523,33 +1549,6 @@ struct mlx5_rxq_ctrl * }/** -* Verify if the queue can be released. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* RX queue index. -* -* @return -* 1 if the queue can be released -* 0 if the queue can not be released, there are references to it. -* Negative errno and rte_errno is set if queue doesn't exist. -*/ -int -mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (!(*priv->rxqs)[idx]) { - rte_errno =EINVAL ; -return -rte_errno; - } - rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); -return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); -} - -/** * Verify the Rx Queue list is empty * * @param dev
@@ -1586,7 +1585,7 @@ struct mlx5_rxq_ctrl ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1650,7 +1649,7 @@ struct mlx5_ind_table_ibv ** @return * An indirection table if found. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1685,7 +1684,7 @@ struct mlx5_ind_table_ibv ** @return * 1 while a reference on it exists, 0 when freed. */ -int +static int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev,struct mlx5_ind_table_ibv *ind_tbl) {
@@ -1969,7 +1968,7 @@ struct mlx5_hrxq ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_rxq_ibv * +static struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2029,7 +2028,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -void +static void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2052,7 +2051,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2095,7 +2094,7 @@ struct mlx5_ind_table_ibv ** @param dev * Pointer to Ethernet device. */ -void +static void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
drivers/net/mlx5/mlx5_rxtx.h +0 -16
@@ -246,7 +246,6 @@ struct mlx5_txq_ctrl {extern uint8_t rss_hash_default_key[]; -int mlx5_check_mprq_support (struct rte_eth_dev *dev);int mlx5_rxq_mprq_enabled (struct mlx5_rxq_data *rxq);int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);
@@ -260,10 +259,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,int mlx5_rx_intr_enable (struct rte_eth_dev *dev,uint16_t rx_queue_id);int mlx5_rx_intr_disable (struct rte_eth_dev *dev,uint16_t rx_queue_id);struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
@@ -271,20 +266,9 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, struct rte_mempool *mp);struct mlx5_rxq_ctrl *mlx5_rxq_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_release (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev, -struct mlx5_ind_table_ibv *ind_tbl);int mlx5_ind_table_ibv_verify (struct rte_eth_dev *dev); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev); struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t rss_key_len, uint64_t hash_fields,
Signature · 1 line
1.8.3.1
Hi Dekel,
Monday, April 29, 2019 2:01 PM, Dekel Peled:
Quoted 4 lines
Subject: [dpdk-dev] [PATCH 0/4] net/mlx5: code cleanup in rx and tx files
During work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
Good cleanup.
I am basically OK w/ the series, you can add my Acked-by to next version. See small comment below.
Quoted 4 lines
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: add missing validation of null pointer
This one should be "fix ..." and not "add ..." + Cc for stable. Since you actually fix a possible segfault.
Quoted 11 lines
net/mlx5: fix description of function return value net/mlx5: move locally used functions to static
drivers/net/mlx5/mlx5_rxq.c | 218 +++++++++++++++++++------------------- ----- drivers/net/mlx5/mlx5_rxtx.h | 20 ---- drivers/net/mlx5/mlx5_txq.c | 13 -- - 3 files changed, 94 insertions(+), 157 deletions(-)--
1.8.3.1
v2 cover net/mlx5: code cleanup in rx and tx files
In reply to Dekel PeledDuring work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
---
v2: change 2nd patch type to "fix"
---
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: fix missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to static
drivers/net/mlx5/mlx5_rxq.c | 218 +++++++++++++++++++------------------------ drivers/net/mlx5/mlx5_rxtx.h | 20 ---- drivers/net/mlx5/mlx5_txq.c | 13 --- 3 files changed, 94 insertions(+), 157 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/4 net/mlx5: remove unused functions
Functions implemented but never called:mlx5_rxq_ibv_releasable()mlx5_rxq_cleanup()mlx5_txq_ibv_releasable()
Function declared but not implemented:rxq_alloc_mprq_buf()
This patch removes these functions from code and header file.
--- drivers/net/mlx5/mlx5_rxq.c | 31 ------------------------------- drivers/net/mlx5/mlx5_rxtx.h | 4 ---- drivers/net/mlx5/mlx5_txq.c | 13 ------------- 3 files changed, 48 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -31
@@ -368,24 +368,6 @@ }/** -* Clean up a RX queue. -* -* Destroy objects, free allocated memory and reset the structure for reuse. -* -* @param rxq_ctrl -* Pointer to RX queue structure. -*/ -void -mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl) -{ -DRV_LOG (DEBUG ,"port %u cleaning up Rx queue %u" , -PORT_ID (rxq_ctrl->priv), rxq_ctrl->rxq.idx); -if (rxq_ctrl->ibv) -mlx5_rxq_ibv_release (rxq_ctrl->ibv); -memset (rxq_ctrl,0 ,sizeof (*rxq_ctrl)); -} - -/** * Returns the per-queue supported offloads. * * @param dev
@@ -1131,19 +1113,6 @@ struct mlx5_rxq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param rxq_ibv -* Verbs Rx queue object. -*/ -int -mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -return (rte_atomic32_read (&rxq_ibv->refcnt) ==1 ); -} - -/** * Callback function to initialize mbufs for Multi-Packet RQ. */ static inline void
drivers/net/mlx5/mlx5_rxtx.h +0 -4
@@ -251,7 +251,6 @@ struct mlx5_txq_ctrl {int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);int mlx5_mprq_alloc_mp (struct rte_eth_dev *dev); -void mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl);int mlx5_rx_queue_setup (struct rte_eth_dev *dev,uint16_t idx,uint16_t desc,unsigned int socket,const struct rte_eth_rxconf *conf,struct rte_mempool *mp);
@@ -263,7 +262,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -int mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv);struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev);void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev);
@@ -276,7 +274,6 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -int rxq_alloc_mprq_buf (struct mlx5_rxq_ctrl *rxq_ctrl);struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n);
@@ -314,7 +311,6 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_txq_ibv *mlx5_txq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_txq_ibv *mlx5_txq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_ibv_release (struct mlx5_txq_ibv *txq_ibv); -int mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv);int mlx5_txq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
drivers/net/mlx5/mlx5_txq.c +0 -13
@@ -668,19 +668,6 @@ struct mlx5_txq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param txq_ibv -* Verbs Tx queue object. -*/ -int -mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv) -{ -assert (txq_ibv); -return (rte_atomic32_read (&txq_ibv->refcnt) ==1 ); -} - -/** * Verify the Verbs Tx queue list is empty * * @param dev
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 1/4] net/mlx5: remove unused functions
Quoted 8 lines · Dekel Peled
Functions implemented but never called:
mlx5_rxq_ibv_releasable()mlx5_rxq_cleanup()mlx5_txq_ibv_releasable()
Quoted 7 lines
Function declared but not implemented:
rxq_alloc_mprq_buf()This patch removes these functions from code and header file.
Signed-off-by Dekel Peled <[email protected]>---
Quoted 117 lines
drivers/net/mlx5/mlx5_rxq.c | 31 ------------------------------- drivers/net/mlx5/mlx5_rxtx.h | 4 ---- drivers/net/mlx5/mlx5_txq.c | 13 ------------- 3 files changed, 48 deletions(-)drivers/net/mlx5/mlx5_rxq.c +0
-31@@ -368,24 +368,6 @@ }/** -* Clean up a RX queue. -* -* Destroy objects, free allocated memory and reset the structure for reuse. -* -* @param rxq_ctrl -* Pointer to RX queue structure. -*/ -void -mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl) -{ -DRV_LOG (DEBUG ,"port %u cleaning up Rx queue %u" , -PORT_ID (rxq_ctrl->priv), rxq_ctrl->rxq.idx); -if (rxq_ctrl->ibv) -mlx5_rxq_ibv_release (rxq_ctrl->ibv); -memset (rxq_ctrl,0 ,sizeof (*rxq_ctrl)); -} - -/** * Returns the per-queue supported offloads. * * @param dev @@ -1131,19 +1113,6 @@ struct mlx5_rxq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param rxq_ibv -* Verbs Rx queue object. -*/ -int -mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -return (rte_atomic32_read (&rxq_ibv->refcnt) ==1 ); -} - -/** * Callback function to initialize mbufs for Multi-Packet RQ. */ static inline void
drivers/net/mlx5/mlx5_rxtx.h +0
-4@@ -251,7 +251,6 @@ struct mlx5_txq_ctrl {int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);int mlx5_mprq_alloc_mp (struct rte_eth_dev *dev); -void mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl);int mlx5_rx_queue_setup (struct rte_eth_dev *dev,uint16_t idx,uint16_t desc,unsigned int socket,const struct rte_eth_rxconf *conf,struct rte_mempool *mp);@@ -263,7 +262,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -int mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv);struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev);void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev);@@ -276,7 +274,6 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -int rxq_alloc_mprq_buf (struct mlx5_rxq_ctrl *rxq_ctrl);struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n);@@ -314,7 +311,6 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_txq_ibv *mlx5_txq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_txq_ibv *mlx5_txq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_ibv_release (struct mlx5_txq_ibv *txq_ibv); -int mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv);int mlx5_txq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,drivers/net/mlx5/mlx5_txq.c +0
-13@@ -668,19 +668,6 @@ struct mlx5_txq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param txq_ibv -* Verbs Tx queue object. -*/ -int -mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv) -{ -assert (txq_ibv); -return (rte_atomic32_read (&txq_ibv->refcnt) ==1 ); -} - -/** * Verify the Verbs Tx queue list is empty * * @param dev Signature · 1 line
1.8.3.1
PATCH v2 2/4 net/mlx5: fix missing validation of null pointer
In reply to Dekel PeledFunction mlx5_rxq_ibv_release() is called in several places. Before each call except one, the input parameter is validated to make sure it is not null.
This patch adds the missing validation where it is missing.
--- drivers/net/mlx5/mlx5_rxq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_rxq.c +2 -1
@@ -617,7 +617,8 @@*/ rxq_data = (*priv->rxqs)[i]; rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -mlx5_rxq_ibv_release (rxq_ctrl->ibv); +if (rxq_ctrl->ibv) +mlx5_rxq_ibv_release (rxq_ctrl->ibv); } free:rte_intr_free_epoll_fd (intr_handle);
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 2/4] net/mlx5: fix missing validation of null pointer
Quoted 22 lines · Dekel Peled
Function
mlx5_rxq_ibv_release()is called in several places. Before each call except one, the input parameter is validated to make sure it is not null.This patch adds the missing validation where it is missing.
Fixes af4f09f28294 ("net/mlx5: prefix all functions with mlx5")Signed-off-by Dekel Peled <[email protected]>---
drivers/net/mlx5/mlx5_rxq.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/mlx5/mlx5_rxq.c +0
-0
drivers/net/mlx5/mlx5_rxq.c line 621
Quoted 6 lines
drivers/net/mlx5/mlx5_rxq.c +2
-1@@ -617,7 +617,8 @@*/ rxq_data = (*priv->rxqs)[i]; rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -mlx5_rxq_ibv_release (rxq_ctrl->ibv); +if (rxq_ctrl->ibv) +mlx5_rxq_ibv_release (rxq_ctrl->ibv);
Please take care of two more things.
1) In mlx5_rx_intr_disable(),mlx5_rxq_ibv_get() isn't paired with mlx5_rxq_ibv_release() This would need a separate patch.
2) In mlx5_rx_intr_vec_disable()
Please fix the comment having the old name - priv_rx_intr_vec_enable(). This should be mlx5_rx_intr_vec_enable()
No need to have a separate patch. You can fix it in this patch.
With the change,
Quoted 6 lines
drivers/net/mlx5/mlx5_rxq.c +0
-0}free:
rte_intr_free_epoll_fd(intr_handle);Signature · 1 line
1.8.3.1
PATCH v2 3/4 net/mlx5: fix description of function return value
In reply to Dekel PeledReturn value of function mlx5_rxq_releasable() was not described correctly in function description.
This patch updates the description to correctly describe the optional return values.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -1546,8 +1546,9 @@ struct mlx5_rxq_ctrl ** RX queue index. * * @return -* 1 if the queue can be released, negative errno otherwise and rte_errno is -* set. +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. */ int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx)
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 3/4] net/mlx5: fix description of function return value
Quoted 6 lines · Dekel Peled
Return value of function
mlx5_rxq_releasable()was not described correctly in function description.
Quoted 8 lines
This patch updates the description to correctly describe the optional return values.
Fixes a6d83b6a9209 ("net/mlx5: standardize on negative errno values")Signed-off-by Dekel Peled <[email protected]>---
Quoted 22 lines
drivers/net/mlx5/mlx5_rxq.c| 5 +++--1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/mlx5/mlx5_rxq.c +3
-2@@ -1546,8 +1546,9 @@ struct mlx5_rxq_ctrl ** RX queue index. * * @return -* 1 if the queue can be released, negative errno otherwise and rte_errno is -* set. +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. */ int
mlx5_rxq_releasable(struct rte_eth_dev *dev, uint16_t idx)Signature · 1 line
1.8.3.1
PATCH v2 4/4 net/mlx5: move locally used functions to static
In reply to Dekel PeledMultiple functions were declared in header file mlx5_rxtx.h, inplemented in mlx5_rxq.c, and called only in mlx5_rxq.c.
This patch moves all these functions declarations into mlx5_rxq.c, as static functions.
Some functions implementation was copied higher in the file to precede the functions calls.
--- drivers/net/mlx5/mlx5_rxq.c | 185 +++++++++++++++++++++---------------------- drivers/net/mlx5/mlx5_rxtx.h | 16 ---- 2 files changed, 92 insertions(+), 109 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +92 -93
@@ -65,7 +65,7 @@* @return * 1 if supported, negative errno value if not. */ -inline int +static inline int mlx5_check_mprq_support (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -418,6 +418,33 @@ }/** +* Verify if the queue can be released. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* RX queue index. +* +* @return +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. +*/ +static int +mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (!(*priv->rxqs)[idx]) { + rte_errno =EINVAL ; +return -rte_errno; + } + rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); +return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); +} + +/** * * @param dev * Pointer to Ethernet device structure.
@@ -505,6 +532,63 @@ }/** +* Get an Rx queue Verbs object. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* Queue index in DPDK Rx queue array +* +* @return +* The Verbs object if it exists. +*/ +static struct mlx5_rxq_ibv * +mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (idx >= priv->rxqs_n) +return NULL ; +if (!rxq_data) +return NULL ; + rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); +if (rxq_ctrl->ibv) +rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); +return rxq_ctrl->ibv; +} + +/** +* Release an Rx verbs queue object. +* +* @param rxq_ibv +* Verbs Rx queue object. +* +* @return +* 1 while a reference on it exists, 0 when freed. +*/ +static int +mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) +{ +assert (rxq_ibv); +assert (rxq_ibv->wq); +assert (rxq_ibv->cq); +if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { +rxq_free_elts (rxq_ibv->rxq_ctrl); +claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); +claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); +if (rxq_ibv->channel) +claim_zero (mlx5_glue->destroy_comp_channel + (rxq_ibv->channel)); +LIST_REMOVE (rxq_ibv, next); +rte_free (rxq_ibv); +return 0 ; + } +return 1 ; +} + +/** * Allocate queue vector and fill epoll fd list for Rx interrupts. * * @param dev
@@ -1032,64 +1116,6 @@ struct mlx5_rxq_ibv * }/** -* Get an Rx queue Verbs object. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* Queue index in DPDK Rx queue array -* -* @return -* The Verbs object if it exists. -*/ -struct mlx5_rxq_ibv * -mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (idx >= priv->rxqs_n) -return NULL ; -if (!rxq_data) -return NULL ; - rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -if (rxq_ctrl->ibv) { -rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); - } -return rxq_ctrl->ibv; -} - -/** -* Release an Rx verbs queue object. -* -* @param rxq_ibv -* Verbs Rx queue object. -* -* @return -* 1 while a reference on it exists, 0 when freed. -*/ -int -mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -assert (rxq_ibv->wq); -assert (rxq_ibv->cq); -if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { -rxq_free_elts (rxq_ibv->rxq_ctrl); -claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); -claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); -if (rxq_ibv->channel) -claim_zero (mlx5_glue->destroy_comp_channel - (rxq_ibv->channel)); -LIST_REMOVE (rxq_ibv, next); -rte_free (rxq_ibv); -return 0 ; - } -return 1 ; -} - -/** * Verify the Verbs Rx queue list is empty * * @param dev
@@ -1538,33 +1564,6 @@ struct mlx5_rxq_ctrl * }/** -* Verify if the queue can be released. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* RX queue index. -* -* @return -* 1 if the queue can be released -* 0 if the queue can not be released, there are references to it. -* Negative errno and rte_errno is set if queue doesn't exist. -*/ -int -mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (!(*priv->rxqs)[idx]) { - rte_errno =EINVAL ; -return -rte_errno; - } - rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); -return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); -} - -/** * Verify the Rx Queue list is empty * * @param dev
@@ -1601,7 +1600,7 @@ struct mlx5_rxq_ctrl ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1665,7 +1664,7 @@ struct mlx5_ind_table_ibv ** @return * An indirection table if found. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1700,7 +1699,7 @@ struct mlx5_ind_table_ibv ** @return * 1 while a reference on it exists, 0 when freed. */ -int +static int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev,struct mlx5_ind_table_ibv *ind_tbl) {
@@ -1984,7 +1983,7 @@ struct mlx5_hrxq ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_rxq_ibv * +static struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2044,7 +2043,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -void +static void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2067,7 +2066,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2110,7 +2109,7 @@ struct mlx5_ind_table_ibv ** @param dev * Pointer to Ethernet device. */ -void +static void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
drivers/net/mlx5/mlx5_rxtx.h +0 -16
@@ -246,7 +246,6 @@ struct mlx5_txq_ctrl {extern uint8_t rss_hash_default_key[]; -int mlx5_check_mprq_support (struct rte_eth_dev *dev);int mlx5_rxq_mprq_enabled (struct mlx5_rxq_data *rxq);int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);
@@ -260,10 +259,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,int mlx5_rx_intr_enable (struct rte_eth_dev *dev,uint16_t rx_queue_id);int mlx5_rx_intr_disable (struct rte_eth_dev *dev,uint16_t rx_queue_id);struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
@@ -271,20 +266,9 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, struct rte_mempool *mp);struct mlx5_rxq_ctrl *mlx5_rxq_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_release (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev, -struct mlx5_ind_table_ibv *ind_tbl);int mlx5_ind_table_ibv_verify (struct rte_eth_dev *dev); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev); struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t rss_key_len, uint64_t hash_fields,
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 4/4] net/mlx5: move locally used functions to static
Quoted 6 lines · Dekel Peled
Multiple functions were declared in header file
mlx5_rxtx.h, inplemented inmlx5_rxq.c, and called only inmlx5_rxq.c.
Quoted 7 lines
This patch moves all these functions declarations into
mlx5_rxq.c, as static functions.
Some functions implementation was copied higher in the file to precede the functions calls.Signed-off-by Dekel Peled <[email protected]>---
Quoted 324 lines
drivers/net/mlx5/mlx5_rxq.c| 185 +++++++++++++++++++++----------------------drivers/net/mlx5/mlx5_rxtx.h| 16 ----2 files changed, 92 insertions(+), 109 deletions(-)drivers/net/mlx5/mlx5_rxq.c +92
-93@@ -65,7 +65,7 @@* @return * 1 if supported, negative errno value if not. */ -inline int +static inline int mlx5_check_mprq_support (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;@@ -418,6 +418,33 @@ }/** +* Verify if the queue can be released. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* RX queue index. +* +* @return +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. +*/ +static int +mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (!(*priv->rxqs)[idx]) { + rte_errno =EINVAL ; +return -rte_errno; + } + rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); +return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); +} + +/** * * @param dev * Pointer to Ethernet device structure. @@ -505,6 +532,63 @@ }/** +* Get an Rx queue Verbs object. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* Queue index in DPDK Rx queue array +* +* @return +* The Verbs object if it exists. +*/ +static struct mlx5_rxq_ibv * +mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (idx >= priv->rxqs_n) +return NULL ; +if (!rxq_data) +return NULL ; + rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); +if (rxq_ctrl->ibv) +rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); +return rxq_ctrl->ibv; +} + +/** +* Release an Rx verbs queue object. +* +* @param rxq_ibv +* Verbs Rx queue object. +* +* @return +* 1 while a reference on it exists, 0 when freed. +*/ +static int +mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) +{ +assert (rxq_ibv); +assert (rxq_ibv->wq); +assert (rxq_ibv->cq); +if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { +rxq_free_elts (rxq_ibv->rxq_ctrl); +claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); +claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); +if (rxq_ibv->channel) +claim_zero (mlx5_glue->destroy_comp_channel + (rxq_ibv->channel)); +LIST_REMOVE (rxq_ibv, next); +rte_free (rxq_ibv); +return 0 ; + } +return 1 ; +} + +/** * Allocate queue vector and fill epoll fd list for Rx interrupts. * * @param dev @@ -1032,64 +1116,6 @@ struct mlx5_rxq_ibv * }/** -* Get an Rx queue Verbs object. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* Queue index in DPDK Rx queue array -* -* @return -* The Verbs object if it exists. -*/ -struct mlx5_rxq_ibv * -mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (idx >= priv->rxqs_n) -return NULL ; -if (!rxq_data) -return NULL ; - rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -if (rxq_ctrl->ibv) { -rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); - } -return rxq_ctrl->ibv; -} - -/** -* Release an Rx verbs queue object. -* -* @param rxq_ibv -* Verbs Rx queue object. -* -* @return -* 1 while a reference on it exists, 0 when freed. -*/ -int -mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -assert (rxq_ibv->wq); -assert (rxq_ibv->cq); -if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { -rxq_free_elts (rxq_ibv->rxq_ctrl); -claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); -claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); -if (rxq_ibv->channel) -claim_zero (mlx5_glue->destroy_comp_channel - (rxq_ibv->channel)); -LIST_REMOVE (rxq_ibv, next); -rte_free (rxq_ibv); -return 0 ; - } -return 1 ; -} - -/** * Verify the Verbs Rx queue list is empty * * @param dev @@ -1538,33 +1564,6 @@ struct mlx5_rxq_ctrl * }/** -* Verify if the queue can be released. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* RX queue index. -* -* @return -* 1 if the queue can be released -* 0 if the queue can not be released, there are references to it. -* Negative errno and rte_errno is set if queue doesn't exist. -*/ -int -mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (!(*priv->rxqs)[idx]) { - rte_errno =EINVAL ; -return -rte_errno; - } - rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); -return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); -} - -/** * Verify the Rx Queue list is empty * * @param dev @@ -1601,7 +1600,7 @@ struct mlx5_rxq_ctrl ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {@@ -1665,7 +1664,7 @@ struct mlx5_ind_table_ibv ** @return * An indirection table if found. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {@@ -1700,7 +1699,7 @@ struct mlx5_ind_table_ibv ** @return * 1 while a reference on it exists, 0 when freed. */ -int +static int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev,struct mlx5_ind_table_ibv *ind_tbl) {@@ -1984,7 +1983,7 @@ struct mlx5_hrxq ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_rxq_ibv * +static struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;@@ -2044,7 +2043,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -void +static void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;@@ -2067,7 +2066,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;@@ -2110,7 +2109,7 @@ struct mlx5_ind_table_ibv ** @param dev * Pointer to Ethernet device. */ -void +static void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;drivers/net/mlx5/mlx5_rxtx.h +0
-16@@ -246,7 +246,6 @@ struct mlx5_txq_ctrl {extern uint8_t rss_hash_default_key[]; -int mlx5_check_mprq_support (struct rte_eth_dev *dev);int mlx5_rxq_mprq_enabled (struct mlx5_rxq_data *rxq);int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);@@ -260,10 +259,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,int mlx5_rx_intr_enable (struct rte_eth_dev *dev,uint16_t rx_queue_id);int mlx5_rx_intr_disable (struct rte_eth_dev *dev,uint16_t rx_queue_id);struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,@@ -271,20 +266,9 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, struct rte_mempool *mp);struct mlx5_rxq_ctrl *mlx5_rxq_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_release (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev, -struct mlx5_ind_table_ibv *ind_tbl);int mlx5_ind_table_ibv_verify (struct rte_eth_dev *dev); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev); struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t rss_key_len, uint64_t hash_fields,Signature · 1 line
1.8.3.1
v3 cover net/mlx5: code cleanup in rx and tx files
In reply to Dekel PeledDuring work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
---
v2: Change 2nd patch type to "fix".
v3: Apply minor code-review comment on 2nd patch.
Add Acked-by in all patches.
---
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: fix missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to static
drivers/net/mlx5/mlx5_rxq.c | 220 +++++++++++++++++++------------------------ drivers/net/mlx5/mlx5_rxtx.h | 20 ---- drivers/net/mlx5/mlx5_txq.c | 13 --- 3 files changed, 95 insertions(+), 158 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/4 net/mlx5: remove unused functions
Functions implemented but never called:mlx5_rxq_ibv_releasable()mlx5_rxq_cleanup()mlx5_txq_ibv_releasable()
Function declared but not implemented:rxq_alloc_mprq_buf()
This patch removes these functions from code and header file.
--- drivers/net/mlx5/mlx5_rxq.c | 31 ------------------------------- drivers/net/mlx5/mlx5_rxtx.h | 4 ---- drivers/net/mlx5/mlx5_txq.c | 13 ------------- 3 files changed, 48 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -31
@@ -353,24 +353,6 @@ }/** -* Clean up a RX queue. -* -* Destroy objects, free allocated memory and reset the structure for reuse. -* -* @param rxq_ctrl -* Pointer to RX queue structure. -*/ -void -mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl) -{ -DRV_LOG (DEBUG ,"port %u cleaning up Rx queue %u" , -PORT_ID (rxq_ctrl->priv), rxq_ctrl->rxq.idx); -if (rxq_ctrl->ibv) -mlx5_rxq_ibv_release (rxq_ctrl->ibv); -memset (rxq_ctrl,0 ,sizeof (*rxq_ctrl)); -} - -/** * Returns the per-queue supported offloads. * * @param dev
@@ -1111,19 +1093,6 @@ struct mlx5_rxq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param rxq_ibv -* Verbs Rx queue object. -*/ -int -mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -return (rte_atomic32_read (&rxq_ibv->refcnt) ==1 ); -} - -/** * Callback function to initialize mbufs for Multi-Packet RQ. */ static inline void
drivers/net/mlx5/mlx5_rxtx.h +0 -4
@@ -249,7 +249,6 @@ struct mlx5_txq_ctrl {int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);int mlx5_mprq_alloc_mp (struct rte_eth_dev *dev); -void mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl);int mlx5_rx_queue_setup (struct rte_eth_dev *dev,uint16_t idx,uint16_t desc,unsigned int socket,const struct rte_eth_rxconf *conf,struct rte_mempool *mp);
@@ -261,7 +260,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -int mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv);struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev);void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev);
@@ -274,7 +272,6 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -int rxq_alloc_mprq_buf (struct mlx5_rxq_ctrl *rxq_ctrl);struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n);
@@ -311,7 +308,6 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_txq_ibv *mlx5_txq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_txq_ibv *mlx5_txq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_ibv_release (struct mlx5_txq_ibv *txq_ibv); -int mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv);int mlx5_txq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
drivers/net/mlx5/mlx5_txq.c +0 -13
@@ -642,19 +642,6 @@ struct mlx5_txq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param txq_ibv -* Verbs Tx queue object. -*/ -int -mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv) -{ -assert (txq_ibv); -return (rte_atomic32_read (&txq_ibv->refcnt) ==1 ); -} - -/** * Verify the Verbs Tx queue list is empty * * @param dev
Signature · 1 line
1.8.3.1
PATCH v3 2/4 net/mlx5: fix missing validation of null pointer
In reply to Dekel PeledFunction mlx5_rxq_ibv_release() is called in several places. Before each call except one, the input parameter is validated to make sure it is not null.
This patch adds the validation where it is missing.
It also changes a priv_ prefix, left in a comment, to mlx5_ prefix.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -593,11 +593,12 @@continue ;/** * Need to access directly the queue to release the reference -* kept in priv_rx_intr_vec_enable(). +* kept in mlx5_rx_intr_vec_enable(). */ rxq_data = (*priv->rxqs)[i]; rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -mlx5_rxq_ibv_release (rxq_ctrl->ibv); +if (rxq_ctrl->ibv) +mlx5_rxq_ibv_release (rxq_ctrl->ibv); } free:rte_intr_free_epoll_fd (intr_handle);
Signature · 1 line
1.8.3.1
PATCH v3 3/4 net/mlx5: fix description of function return value
In reply to Dekel PeledReturn value of function mlx5_rxq_releasable() was not described correctly in function description.
This patch updates the description to correctly describe the optional return values.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -1526,8 +1526,9 @@ struct mlx5_rxq_ctrl ** RX queue index. * * @return -* 1 if the queue can be released, negative errno otherwise and rte_errno is -* set. +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. */ int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx)
Signature · 1 line
1.8.3.1
PATCH v3 4/4 net/mlx5: move locally used functions to static
In reply to Dekel PeledMultiple functions were declared in header file mlx5_rxtx.h, inplemented in mlx5_rxq.c, and called only in mlx5_rxq.c.
This patch moves all these functions declarations into mlx5_rxq.c, as static functions.
Some functions implementation was copied higher in the file to precede the functions calls.
--- drivers/net/mlx5/mlx5_rxq.c | 185 +++++++++++++++++++++---------------------- drivers/net/mlx5/mlx5_rxtx.h | 16 ---- 2 files changed, 92 insertions(+), 109 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +92 -93
@@ -65,7 +65,7 @@* @return * 1 if supported, negative errno value if not. */ -inline int +static inline int mlx5_check_mprq_support (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -398,6 +398,33 @@ }/** +* Verify if the queue can be released. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* RX queue index. +* +* @return +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. +*/ +static int +mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (!(*priv->rxqs)[idx]) { + rte_errno =EINVAL ; +return -rte_errno; + } + rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); +return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); +} + +/** * * @param dev * Pointer to Ethernet device structure.
@@ -485,6 +512,63 @@ }/** +* Get an Rx queue Verbs object. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* Queue index in DPDK Rx queue array +* +* @return +* The Verbs object if it exists. +*/ +static struct mlx5_rxq_ibv * +mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (idx >= priv->rxqs_n) +return NULL ; +if (!rxq_data) +return NULL ; + rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); +if (rxq_ctrl->ibv) +rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); +return rxq_ctrl->ibv; +} + +/** +* Release an Rx verbs queue object. +* +* @param rxq_ibv +* Verbs Rx queue object. +* +* @return +* 1 while a reference on it exists, 0 when freed. +*/ +static int +mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) +{ +assert (rxq_ibv); +assert (rxq_ibv->wq); +assert (rxq_ibv->cq); +if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { +rxq_free_elts (rxq_ibv->rxq_ctrl); +claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); +claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); +if (rxq_ibv->channel) +claim_zero (mlx5_glue->destroy_comp_channel + (rxq_ibv->channel)); +LIST_REMOVE (rxq_ibv, next); +rte_free (rxq_ibv); +return 0 ; + } +return 1 ; +} + +/** * Allocate queue vector and fill epoll fd list for Rx interrupts. * * @param dev
@@ -1012,64 +1096,6 @@ struct mlx5_rxq_ibv * }/** -* Get an Rx queue Verbs object. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* Queue index in DPDK Rx queue array -* -* @return -* The Verbs object if it exists. -*/ -struct mlx5_rxq_ibv * -mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (idx >= priv->rxqs_n) -return NULL ; -if (!rxq_data) -return NULL ; - rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -if (rxq_ctrl->ibv) { -rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); - } -return rxq_ctrl->ibv; -} - -/** -* Release an Rx verbs queue object. -* -* @param rxq_ibv -* Verbs Rx queue object. -* -* @return -* 1 while a reference on it exists, 0 when freed. -*/ -int -mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -assert (rxq_ibv->wq); -assert (rxq_ibv->cq); -if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { -rxq_free_elts (rxq_ibv->rxq_ctrl); -claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); -claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); -if (rxq_ibv->channel) -claim_zero (mlx5_glue->destroy_comp_channel - (rxq_ibv->channel)); -LIST_REMOVE (rxq_ibv, next); -rte_free (rxq_ibv); -return 0 ; - } -return 1 ; -} - -/** * Verify the Verbs Rx queue list is empty * * @param dev
@@ -1518,33 +1544,6 @@ struct mlx5_rxq_ctrl * }/** -* Verify if the queue can be released. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* RX queue index. -* -* @return -* 1 if the queue can be released -* 0 if the queue can not be released, there are references to it. -* Negative errno and rte_errno is set if queue doesn't exist. -*/ -int -mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (!(*priv->rxqs)[idx]) { - rte_errno =EINVAL ; -return -rte_errno; - } - rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); -return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); -} - -/** * Verify the Rx Queue list is empty * * @param dev
@@ -1581,7 +1580,7 @@ struct mlx5_rxq_ctrl ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1645,7 +1644,7 @@ struct mlx5_ind_table_ibv ** @return * An indirection table if found. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1680,7 +1679,7 @@ struct mlx5_ind_table_ibv ** @return * 1 while a reference on it exists, 0 when freed. */ -int +static int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev,struct mlx5_ind_table_ibv *ind_tbl) {
@@ -1964,7 +1963,7 @@ struct mlx5_hrxq ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_rxq_ibv * +static struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2024,7 +2023,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -void +static void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2047,7 +2046,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2090,7 +2089,7 @@ struct mlx5_ind_table_ibv ** @param dev * Pointer to Ethernet device. */ -void +static void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
drivers/net/mlx5/mlx5_rxtx.h +0 -16
@@ -244,7 +244,6 @@ struct mlx5_txq_ctrl {extern uint8_t rss_hash_default_key[]; -int mlx5_check_mprq_support (struct rte_eth_dev *dev);int mlx5_rxq_mprq_enabled (struct mlx5_rxq_data *rxq);int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);
@@ -258,10 +257,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,int mlx5_rx_intr_enable (struct rte_eth_dev *dev,uint16_t rx_queue_id);int mlx5_rx_intr_disable (struct rte_eth_dev *dev,uint16_t rx_queue_id);struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
@@ -269,20 +264,9 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, struct rte_mempool *mp);struct mlx5_rxq_ctrl *mlx5_rxq_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_release (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev, -struct mlx5_ind_table_ibv *ind_tbl);int mlx5_ind_table_ibv_verify (struct rte_eth_dev *dev); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev); struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t rss_key_len, uint64_t hash_fields,
Signature · 1 line
1.8.3.1
Dekel,
Sunday, May 5, 2019 4:09 PM, Dekel Peled:
Quoted 10 lines
Subject: [PATCH v3 0/4] net/mlx5: code cleanup in rx and tx files
During work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
---
v2: Change 2nd patch type to "fix".
v3: Apply minor code-review comment on 2nd patch.
Add Acked-by in all patches.
---
I was trying to apply your patch but hit clang compilation issue, please address:
error: static function
'mlx5_check_mprq_support' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline]
if (mlx5_check_mprq_support(dev) < 0)
^/.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_rxtx.h:248:1: note: use 'static' to give inline
function 'mlx5_mprq_enabled' internal linkage
int mlx5_mprq_enabled(struct rte_eth_dev *dev);
^
static
/.autodirect/swgwork/shahafs/workspace/dpdk.org/drivers/net/mlx5/mlx5_rxq.c:69:1: note: 'mlx5_check_mprq_support'
declared heremlx5_check_mprq_support(struct rte_eth_dev *dev)
Quoted 15 lines
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: fix missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to staticdrivers/net/mlx5/mlx5_rxq.c | 220 +++++++++++++++++++------------------- ----- drivers/net/mlx5/mlx5_rxtx.h | 20 ---- drivers/net/mlx5/mlx5_txq.c | 13 -- - 3 files changed, 95 insertions(+), 158 deletions(-)--
1.8.3.1
v4 cover net/mlx5: code cleanup in rx and tx files
In reply to Dekel PeledDuring work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
---
v2: Change 2nd patch type to "fix".
v3: Apply minor code-review comment on 2nd patch.
Add Acked-by in all patches.
v4: Fix compilaton issue in 4th patch.
---
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: fix missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to static
drivers/net/mlx5/mlx5_rxq.c | 218 +++++++++++++++++++------------------------ drivers/net/mlx5/mlx5_rxtx.h | 19 ---- drivers/net/mlx5/mlx5_txq.c | 13 --- 3 files changed, 94 insertions(+), 156 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/4 net/mlx5: remove unused functions
Functions implemented but never called:mlx5_rxq_ibv_releasable()mlx5_rxq_cleanup()mlx5_txq_ibv_releasable()
Function declared but not implemented:rxq_alloc_mprq_buf()
This patch removes these functions from code and header file.
--- drivers/net/mlx5/mlx5_rxq.c | 31 ------------------------------- drivers/net/mlx5/mlx5_rxtx.h | 4 ---- drivers/net/mlx5/mlx5_txq.c | 13 ------------- 3 files changed, 48 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +0 -31
@@ -353,24 +353,6 @@ }/** -* Clean up a RX queue. -* -* Destroy objects, free allocated memory and reset the structure for reuse. -* -* @param rxq_ctrl -* Pointer to RX queue structure. -*/ -void -mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl) -{ -DRV_LOG (DEBUG ,"port %u cleaning up Rx queue %u" , -PORT_ID (rxq_ctrl->priv), rxq_ctrl->rxq.idx); -if (rxq_ctrl->ibv) -mlx5_rxq_ibv_release (rxq_ctrl->ibv); -memset (rxq_ctrl,0 ,sizeof (*rxq_ctrl)); -} - -/** * Returns the per-queue supported offloads. * * @param dev
@@ -1112,19 +1094,6 @@ struct mlx5_rxq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param rxq_ibv -* Verbs Rx queue object. -*/ -int -mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -return (rte_atomic32_read (&rxq_ibv->refcnt) ==1 ); -} - -/** * Callback function to initialize mbufs for Multi-Packet RQ. */ static inline void
drivers/net/mlx5/mlx5_rxtx.h +0 -4
@@ -249,7 +249,6 @@ struct mlx5_txq_ctrl {int mlx5_mprq_enabled (struct rte_eth_dev *dev);int mlx5_mprq_free_mp (struct rte_eth_dev *dev);int mlx5_mprq_alloc_mp (struct rte_eth_dev *dev); -void mlx5_rxq_cleanup (struct mlx5_rxq_ctrl *rxq_ctrl);int mlx5_rx_queue_setup (struct rte_eth_dev *dev,uint16_t idx,uint16_t desc,unsigned int socket,const struct rte_eth_rxconf *conf,struct rte_mempool *mp);
@@ -261,7 +260,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -int mlx5_rxq_ibv_releasable (struct mlx5_rxq_ibv *rxq_ibv);struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev);void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev);
@@ -274,7 +272,6 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -int rxq_alloc_mprq_buf (struct mlx5_rxq_ctrl *rxq_ctrl);struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n);
@@ -311,7 +308,6 @@ int mlx5_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,struct mlx5_txq_ibv *mlx5_txq_ibv_new (struct rte_eth_dev *dev,uint16_t idx);struct mlx5_txq_ibv *mlx5_txq_ibv_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_txq_ibv_release (struct mlx5_txq_ibv *txq_ibv); -int mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv);int mlx5_txq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_txq_ctrl *mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
drivers/net/mlx5/mlx5_txq.c +0 -13
@@ -642,19 +642,6 @@ struct mlx5_txq_ibv * }/** -* Return true if a single reference exists on the object. -* -* @param txq_ibv -* Verbs Tx queue object. -*/ -int -mlx5_txq_ibv_releasable (struct mlx5_txq_ibv *txq_ibv) -{ -assert (txq_ibv); -return (rte_atomic32_read (&txq_ibv->refcnt) ==1 ); -} - -/** * Verify the Verbs Tx queue list is empty * * @param dev
Signature · 1 line
1.8.3.1
PATCH v4 2/4 net/mlx5: fix missing validation of null pointer
In reply to Dekel PeledFunction mlx5_rxq_ibv_release() is called in several places. Before each call except one, the input parameter is validated to make sure it is not null.
This patch adds the validation where it is missing.
It also changes a priv_ prefix, left in a comment, to mlx5_ prefix.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -593,11 +593,12 @@continue ;/** * Need to access directly the queue to release the reference -* kept in priv_rx_intr_vec_enable(). +* kept in mlx5_rx_intr_vec_enable(). */ rxq_data = (*priv->rxqs)[i]; rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -mlx5_rxq_ibv_release (rxq_ctrl->ibv); +if (rxq_ctrl->ibv) +mlx5_rxq_ibv_release (rxq_ctrl->ibv); } free:rte_intr_free_epoll_fd (intr_handle);
Signature · 1 line
1.8.3.1
PATCH v4 3/4 net/mlx5: fix description of function return value
In reply to Dekel PeledReturn value of function mlx5_rxq_releasable() was not described correctly in function description.
This patch updates the description to correctly describe the optional return values.
--- drivers/net/mlx5/mlx5_rxq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +3 -2
@@ -1527,8 +1527,9 @@ struct mlx5_rxq_ctrl ** RX queue index. * * @return -* 1 if the queue can be released, negative errno otherwise and rte_errno is -* set. +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. */ int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx)
Signature · 1 line
1.8.3.1
PATCH v4 4/4 net/mlx5: move locally used functions to static
In reply to Dekel PeledMultiple functions were declared in header file mlx5_rxtx.h, inplemented in mlx5_rxq.c, and called only in mlx5_rxq.c.
This patch moves all these functions declarations into mlx5_rxq.c, as static functions.
Some functions implementation was copied higher in the file to precede the functions calls.
--- drivers/net/mlx5/mlx5_rxq.c | 183 +++++++++++++++++++++---------------------- drivers/net/mlx5/mlx5_rxtx.h | 15 ---- 2 files changed, 91 insertions(+), 107 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +91 -92
@@ -398,6 +398,33 @@ }/** +* Verify if the queue can be released. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* RX queue index. +* +* @return +* 1 if the queue can be released +* 0 if the queue can not be released, there are references to it. +* Negative errno and rte_errno is set if queue doesn't exist. +*/ +static int +mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (!(*priv->rxqs)[idx]) { + rte_errno =EINVAL ; +return -rte_errno; + } + rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); +return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); +} + +/** * * @param dev * Pointer to Ethernet device structure.
@@ -485,6 +512,63 @@ }/** +* Get an Rx queue Verbs object. +* +* @param dev +* Pointer to Ethernet device. +* @param idx +* Queue index in DPDK Rx queue array +* +* @return +* The Verbs object if it exists. +*/ +static struct mlx5_rxq_ibv * +mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; +struct mlx5_rxq_ctrl *rxq_ctrl; + +if (idx >= priv->rxqs_n) +return NULL ; +if (!rxq_data) +return NULL ; + rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); +if (rxq_ctrl->ibv) +rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); +return rxq_ctrl->ibv; +} + +/** +* Release an Rx verbs queue object. +* +* @param rxq_ibv +* Verbs Rx queue object. +* +* @return +* 1 while a reference on it exists, 0 when freed. +*/ +static int +mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) +{ +assert (rxq_ibv); +assert (rxq_ibv->wq); +assert (rxq_ibv->cq); +if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { +rxq_free_elts (rxq_ibv->rxq_ctrl); +claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); +claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); +if (rxq_ibv->channel) +claim_zero (mlx5_glue->destroy_comp_channel + (rxq_ibv->channel)); +LIST_REMOVE (rxq_ibv, next); +rte_free (rxq_ibv); +return 0 ; + } +return 1 ; +} + +/** * Allocate queue vector and fill epoll fd list for Rx interrupts. * * @param dev
@@ -1013,64 +1097,6 @@ struct mlx5_rxq_ibv * }/** -* Get an Rx queue Verbs object. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* Queue index in DPDK Rx queue array -* -* @return -* The Verbs object if it exists. -*/ -struct mlx5_rxq_ibv * -mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (idx >= priv->rxqs_n) -return NULL ; -if (!rxq_data) -return NULL ; - rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); -if (rxq_ctrl->ibv) { -rte_atomic32_inc (&rxq_ctrl->ibv->refcnt); - } -return rxq_ctrl->ibv; -} - -/** -* Release an Rx verbs queue object. -* -* @param rxq_ibv -* Verbs Rx queue object. -* -* @return -* 1 while a reference on it exists, 0 when freed. -*/ -int -mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv) -{ -assert (rxq_ibv); -assert (rxq_ibv->wq); -assert (rxq_ibv->cq); -if (rte_atomic32_dec_and_test (&rxq_ibv->refcnt)) { -rxq_free_elts (rxq_ibv->rxq_ctrl); -claim_zero (mlx5_glue->destroy_wq (rxq_ibv->wq)); -claim_zero (mlx5_glue->destroy_cq (rxq_ibv->cq)); -if (rxq_ibv->channel) -claim_zero (mlx5_glue->destroy_comp_channel - (rxq_ibv->channel)); -LIST_REMOVE (rxq_ibv, next); -rte_free (rxq_ibv); -return 0 ; - } -return 1 ; -} - -/** * Verify the Verbs Rx queue list is empty * * @param dev
@@ -1519,33 +1545,6 @@ struct mlx5_rxq_ctrl * }/** -* Verify if the queue can be released. -* -* @param dev -* Pointer to Ethernet device. -* @param idx -* RX queue index. -* -* @return -* 1 if the queue can be released -* 0 if the queue can not be released, there are references to it. -* Negative errno and rte_errno is set if queue doesn't exist. -*/ -int -mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx) -{ -struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_rxq_ctrl *rxq_ctrl; - -if (!(*priv->rxqs)[idx]) { - rte_errno =EINVAL ; -return -rte_errno; - } - rxq_ctrl = container_of((*priv->rxqs)[idx], struct mlx5_rxq_ctrl, rxq); -return (rte_atomic32_read (&rxq_ctrl->refcnt) ==1 ); -} - -/** * Verify the Rx Queue list is empty * * @param dev
@@ -1582,7 +1581,7 @@ struct mlx5_rxq_ctrl ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1646,7 +1645,7 @@ struct mlx5_ind_table_ibv ** @return * An indirection table if found. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev,const uint16_t *queues,uint32_t queues_n) {
@@ -1681,7 +1680,7 @@ struct mlx5_ind_table_ibv ** @return * 1 while a reference on it exists, 0 when freed. */ -int +static int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev,struct mlx5_ind_table_ibv *ind_tbl) {
@@ -1965,7 +1964,7 @@ struct mlx5_hrxq ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_rxq_ibv * +static struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2025,7 +2024,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -void +static void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2048,7 +2047,7 @@ struct mlx5_rxq_ibv ** @return * The Verbs object initialised, NULL otherwise and rte_errno is set. */ -struct mlx5_ind_table_ibv * +static struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -2091,7 +2090,7 @@ struct mlx5_ind_table_ibv ** @param dev * Pointer to Ethernet device. */ -void +static void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
drivers/net/mlx5/mlx5_rxtx.h +0 -15
@@ -258,10 +258,6 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,int mlx5_rx_intr_enable (struct rte_eth_dev *dev,uint16_t rx_queue_id);int mlx5_rx_intr_disable (struct rte_eth_dev *dev,uint16_t rx_queue_id);struct mlx5_rxq_ibv *mlx5_rxq_ibv_new (struct rte_eth_dev *dev,uint16_t idx); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_get (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_ibv_release (struct mlx5_rxq_ibv *rxq_ibv); -struct mlx5_rxq_ibv *mlx5_rxq_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_rxq_ibv_drop_release (struct rte_eth_dev *dev);int mlx5_rxq_ibv_verify (struct rte_eth_dev *dev); struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, unsigned int socket,
@@ -269,20 +265,9 @@ struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, struct rte_mempool *mp);struct mlx5_rxq_ctrl *mlx5_rxq_get (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_release (struct rte_eth_dev *dev,uint16_t idx); -int mlx5_rxq_releasable (struct rte_eth_dev *dev,uint16_t idx);int mlx5_rxq_verify (struct rte_eth_dev *dev);int rxq_alloc_elts (struct mlx5_rxq_ctrl *rxq_ctrl); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_new (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_get (struct rte_eth_dev *dev, -const uint16_t *queues, -uint32_t queues_n); -int mlx5_ind_table_ibv_release (struct rte_eth_dev *dev, -struct mlx5_ind_table_ibv *ind_tbl);int mlx5_ind_table_ibv_verify (struct rte_eth_dev *dev); -struct mlx5_ind_table_ibv *mlx5_ind_table_ibv_drop_new (struct rte_eth_dev *dev); -void mlx5_ind_table_ibv_drop_release (struct rte_eth_dev *dev); struct mlx5_hrxq *mlx5_hrxq_new(struct rte_eth_dev *dev, const uint8_t *rss_key, uint32_t rss_key_len, uint64_t hash_fields,
Signature · 1 line
1.8.3.1
Wednesday, May 8, 2019 11:30 AM, Dekel Peled:
Quoted 10 lines
Subject: [dpdk-dev] [PATCH v4 0/4] net/mlx5: code cleanup in rx and tx files
During work on Rx feature I did some cleanup actions. This series includes those changes divided by their type.
---
v2: Change 2nd patch type to "fix".
v3: Apply minor code-review comment on 2nd patch.
Add Acked-by in all patches.
v4: Fix compilaton issue in 4th patch.
Series applied to next-net-mlx, thanks.
Quoted 16 lines
---
Dekel Peled (4):
net/mlx5: remove unused functions net/mlx5: fix missing validation of null pointer net/mlx5: fix description of function return value net/mlx5: move locally used functions to staticdrivers/net/mlx5/mlx5_rxq.c | 218 +++++++++++++++++++------------------- ----- drivers/net/mlx5/mlx5_rxtx.h | 19 ---- drivers/net/mlx5/mlx5_txq.c | 13 -- - 3 files changed, 94 insertions(+), 156 deletions(-)--
1.8.3.1