[dpdk-dev,2/2] net/ena: convert to new Rx offloads API
diff mbox

Message ID 1516103563-9275-3-git-send-email-rk@semihalf.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Rafal Kozik Jan. 16, 2018, 11:52 a.m. UTC
Ethdev Rx offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")

This commit support the new Rx offloads API.

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 36 ++++++++++++++++++++++++++++++++++--
 drivers/net/ena/ena_ethdev.h |  2 ++
 2 files changed, 36 insertions(+), 2 deletions(-)

Comments

Shahaf Shuler Jan. 17, 2018, 6:57 a.m. UTC | #1
Tuesday, January 16, 2018 1:53 PM, Rafal Kozik:
> Ethdev Rx offloads API has changed since:
> 
> commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
> 
> This commit support the new Rx offloads API.
> 
> Signed-off-by: Rafal Kozik <rk@semihalf.com>
> ---
>  drivers/net/ena/ena_ethdev.c | 36
> ++++++++++++++++++++++++++++++++++--
>  drivers/net/ena/ena_ethdev.h |  2 ++
>  2 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index 6473776..f069ca8 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -237,6 +237,8 @@ static int ena_rss_reta_query(struct rte_eth_dev
> *dev,  static int ena_get_sset_count(struct rte_eth_dev *dev, int sset);
> static bool ena_are_tx_queue_offloads_allowed(struct ena_adapter
> *adapter,
>  					      uint64_t offloads);
> +static bool ena_are_rx_queue_offloads_allowed(struct ena_adapter
> *adapter,
> +					      uint64_t offloads);
> 
>  static const struct eth_dev_ops ena_dev_ops = {
>  	.dev_configure        = ena_dev_configure,
> @@ -766,7 +768,8 @@ static uint32_t ena_get_mtu_conf(struct
> ena_adapter *adapter)  {
>  	uint32_t max_frame_len = adapter->max_mtu;
> 
> -	if (adapter->rte_eth_dev_data->dev_conf.rxmode.jumbo_frame ==
> 1)
> +	if (adapter->rte_eth_dev_data->dev_conf.rxmode.offloads &
> +	    DEV_RX_OFFLOAD_JUMBO_FRAME)
>  		max_frame_len =
>  			adapter->rte_eth_dev_data-
> >dev_conf.rxmode.max_rx_pkt_len;
> 
> @@ -1065,7 +1068,7 @@ static int ena_rx_queue_setup(struct rte_eth_dev
> *dev,
>  			      uint16_t queue_idx,
>  			      uint16_t nb_desc,
>  			      __rte_unused unsigned int socket_id,
> -			      __rte_unused const struct rte_eth_rxconf
> *rx_conf,
> +			      const struct rte_eth_rxconf *rx_conf,
>  			      struct rte_mempool *mp)
>  {
>  	struct ena_com_create_io_ctx ctx =
> @@ -1101,6 +1104,11 @@ static int ena_rx_queue_setup(struct
> rte_eth_dev *dev,
>  		return -EINVAL;
>  	}
> 
> +	if (!ena_are_rx_queue_offloads_allowed(adapter, rx_conf-
> >offloads)) {
> +		RTE_LOG(ERR, PMD, "Unsupported queue offloads\n");
> +		return -EINVAL;
> +	}
> +
>  	ena_qid = ENA_IO_RXQ_IDX(queue_idx);
> 
>  	ctx.qid = ena_qid;
> @@ -1405,6 +1413,7 @@ static int ena_dev_configure(struct rte_eth_dev
> *dev)
>  	struct ena_adapter *adapter =
>  		(struct ena_adapter *)(dev->data->dev_private);
>  	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
> +	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
> 
>  	if ((tx_offloads & adapter->tx_supported_offloads) != tx_offloads) {
>  		RTE_LOG(ERR, PMD, "Some Tx offloads are not supported "
> @@ -1413,6 +1422,13 @@ static int ena_dev_configure(struct rte_eth_dev
> *dev)
>  		return -ENOTSUP;
>  	}
> 
> +	if ((rx_offloads & adapter->rx_supported_offloads) != rx_offloads) {
> +		RTE_LOG(ERR, PMD, "Some Rx offloads are not supported "
> +		    "requested 0x%lx supported 0x%lx\n",
> +		    rx_offloads, adapter->rx_supported_offloads);
> +		return -ENOTSUP;
> +	}
> +

Same comment about the 32b compilation. 

>  	if (!(adapter->state == ENA_ADAPTER_STATE_INIT ||
>  	      adapter->state == ENA_ADAPTER_STATE_STOPPED)) {
>  		PMD_INIT_LOG(ERR, "Illegal adapter state: %d", @@ -1434,6
> +1450,7 @@ static int ena_dev_configure(struct rte_eth_dev *dev)
>  	}
> 
>  	adapter->tx_selected_offloads = tx_offloads;
> +	adapter->rx_selected_offloads = rx_offloads;
>  	return 0;
>  }
> 
> @@ -1475,6 +1492,19 @@ static bool
> ena_are_tx_queue_offloads_allowed(struct ena_adapter *adapter,
>  	return true;
>  }
> 
> +static bool ena_are_rx_queue_offloads_allowed(struct ena_adapter
> *adapter,
> +					      uint64_t offloads)
> +{
> +	uint64_t port_offloads = adapter->rx_selected_offloads;
> +
> +	/* Check if port supports all requested offloads.
> +	 * True if all offloads selected for queue are set for port.
> +	 */
> +	if ((offloads & port_offloads) != offloads)
> +		return false;
> +	return true;
> +}
> +
>  static void ena_infos_get(struct rte_eth_dev *dev,
>  			  struct rte_eth_dev_info *dev_info)  { @@ -1529,6
> +1559,7 @@ static void ena_infos_get(struct rte_eth_dev *dev,
> 
>  	/* Inform framework about available features */
>  	dev_info->rx_offload_capa = rx_feat;
> +	dev_info->rx_queue_offload_capa = rx_feat;
>  	dev_info->tx_offload_capa = tx_feat;
>  	dev_info->tx_queue_offload_capa = tx_feat;
> 
> @@ -1541,6 +1572,7 @@ static void ena_infos_get(struct rte_eth_dev *dev,
>  	dev_info->reta_size = ENA_RX_RSS_TABLE_SIZE;
> 
>  	adapter->tx_supported_offloads = tx_feat;
> +	adapter->rx_supported_offloads = rx_feat;
>  }
> 
>  static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf
> **rx_pkts, diff --git a/drivers/net/ena/ena_ethdev.h
> b/drivers/net/ena/ena_ethdev.h index 3e72777..394d05e 100644
> --- a/drivers/net/ena/ena_ethdev.h
> +++ b/drivers/net/ena/ena_ethdev.h
> @@ -178,6 +178,8 @@ struct ena_adapter {
> 
>  	uint64_t tx_supported_offloads;
>  	uint64_t tx_selected_offloads;
> +	uint64_t rx_supported_offloads;
> +	uint64_t rx_selected_offloads;
>  };
> 
>  #endif /* _ENA_ETHDEV_H_ */

Reviewed-By: Shahaf Shuler <shahafs@mellanox.com>

> --
> 2.7.4

Patch
diff mbox

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 6473776..f069ca8 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -237,6 +237,8 @@  static int ena_rss_reta_query(struct rte_eth_dev *dev,
 static int ena_get_sset_count(struct rte_eth_dev *dev, int sset);
 static bool ena_are_tx_queue_offloads_allowed(struct ena_adapter *adapter,
 					      uint64_t offloads);
+static bool ena_are_rx_queue_offloads_allowed(struct ena_adapter *adapter,
+					      uint64_t offloads);
 
 static const struct eth_dev_ops ena_dev_ops = {
 	.dev_configure        = ena_dev_configure,
@@ -766,7 +768,8 @@  static uint32_t ena_get_mtu_conf(struct ena_adapter *adapter)
 {
 	uint32_t max_frame_len = adapter->max_mtu;
 
-	if (adapter->rte_eth_dev_data->dev_conf.rxmode.jumbo_frame == 1)
+	if (adapter->rte_eth_dev_data->dev_conf.rxmode.offloads &
+	    DEV_RX_OFFLOAD_JUMBO_FRAME)
 		max_frame_len =
 			adapter->rte_eth_dev_data->dev_conf.rxmode.max_rx_pkt_len;
 
@@ -1065,7 +1068,7 @@  static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 			      uint16_t queue_idx,
 			      uint16_t nb_desc,
 			      __rte_unused unsigned int socket_id,
-			      __rte_unused const struct rte_eth_rxconf *rx_conf,
+			      const struct rte_eth_rxconf *rx_conf,
 			      struct rte_mempool *mp)
 {
 	struct ena_com_create_io_ctx ctx =
@@ -1101,6 +1104,11 @@  static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
+	if (!ena_are_rx_queue_offloads_allowed(adapter, rx_conf->offloads)) {
+		RTE_LOG(ERR, PMD, "Unsupported queue offloads\n");
+		return -EINVAL;
+	}
+
 	ena_qid = ENA_IO_RXQ_IDX(queue_idx);
 
 	ctx.qid = ena_qid;
@@ -1405,6 +1413,7 @@  static int ena_dev_configure(struct rte_eth_dev *dev)
 	struct ena_adapter *adapter =
 		(struct ena_adapter *)(dev->data->dev_private);
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
+	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 
 	if ((tx_offloads & adapter->tx_supported_offloads) != tx_offloads) {
 		RTE_LOG(ERR, PMD, "Some Tx offloads are not supported "
@@ -1413,6 +1422,13 @@  static int ena_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
+	if ((rx_offloads & adapter->rx_supported_offloads) != rx_offloads) {
+		RTE_LOG(ERR, PMD, "Some Rx offloads are not supported "
+		    "requested 0x%lx supported 0x%lx\n",
+		    rx_offloads, adapter->rx_supported_offloads);
+		return -ENOTSUP;
+	}
+
 	if (!(adapter->state == ENA_ADAPTER_STATE_INIT ||
 	      adapter->state == ENA_ADAPTER_STATE_STOPPED)) {
 		PMD_INIT_LOG(ERR, "Illegal adapter state: %d",
@@ -1434,6 +1450,7 @@  static int ena_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	adapter->tx_selected_offloads = tx_offloads;
+	adapter->rx_selected_offloads = rx_offloads;
 	return 0;
 }
 
@@ -1475,6 +1492,19 @@  static bool ena_are_tx_queue_offloads_allowed(struct ena_adapter *adapter,
 	return true;
 }
 
+static bool ena_are_rx_queue_offloads_allowed(struct ena_adapter *adapter,
+					      uint64_t offloads)
+{
+	uint64_t port_offloads = adapter->rx_selected_offloads;
+
+	/* Check if port supports all requested offloads.
+	 * True if all offloads selected for queue are set for port.
+	 */
+	if ((offloads & port_offloads) != offloads)
+		return false;
+	return true;
+}
+
 static void ena_infos_get(struct rte_eth_dev *dev,
 			  struct rte_eth_dev_info *dev_info)
 {
@@ -1529,6 +1559,7 @@  static void ena_infos_get(struct rte_eth_dev *dev,
 
 	/* Inform framework about available features */
 	dev_info->rx_offload_capa = rx_feat;
+	dev_info->rx_queue_offload_capa = rx_feat;
 	dev_info->tx_offload_capa = tx_feat;
 	dev_info->tx_queue_offload_capa = tx_feat;
 
@@ -1541,6 +1572,7 @@  static void ena_infos_get(struct rte_eth_dev *dev,
 	dev_info->reta_size = ENA_RX_RSS_TABLE_SIZE;
 
 	adapter->tx_supported_offloads = tx_feat;
+	adapter->rx_supported_offloads = rx_feat;
 }
 
 static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h
index 3e72777..394d05e 100644
--- a/drivers/net/ena/ena_ethdev.h
+++ b/drivers/net/ena/ena_ethdev.h
@@ -178,6 +178,8 @@  struct ena_adapter {
 
 	uint64_t tx_supported_offloads;
 	uint64_t tx_selected_offloads;
+	uint64_t rx_supported_offloads;
+	uint64_t rx_selected_offloads;
 };
 
 #endif /* _ENA_ETHDEV_H_ */