[dpdk-dev,v2,2/2] net/i40e: convert to new Tx offloads API
Checks
Commit Message
Ethdev Tx offloads API has changed since:
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")
This commit support the new Tx offloads API.
Signed-off-by: Yanglong Wu <yanglong.wu@intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 1 +
drivers/net/i40e/i40e_ethdev_vf.c | 1 +
drivers/net/i40e/i40e_rxtx.c | 24 ++++++++++++++++++++++++
drivers/net/i40e/i40e_rxtx.h | 1 +
4 files changed, 27 insertions(+)
Comments
> -----Original Message-----
> From: Wu, Yanglong
> Sent: Thursday, March 29, 2018 1:27 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Dai, Wei <wei.dai@intel.com>; Xing,
> Beilei <beilei.xing@intel.com>; Wu, Yanglong <yanglong.wu@intel.com>
> Subject: [PATCH v2 2/2] net/i40e: convert to new Tx offloads API
I think this is v3, not v2, please keep this correct and always update change log
>
>
> +static int
> +i40e_check_tx_queue_offloads(struct rte_eth_dev *dev, uint64_t
> +requested) {
> + struct rte_eth_dev_info dev_info;
> + uint64_t mandatory = dev->data->dev_conf.txmode.offloads;
> + uint64_t supported; /* All per port offloads */
> +
> + dev->dev_ops->dev_infos_get(dev, &dev_info);
> + supported = dev_info.tx_offload_capa ^
> dev_info.tx_queue_offload_capa;
> + if ((requested & dev_info.tx_queue_offload_capa) != requested)
> + return 0; /* requested range check */
I think the fix for rx should also be applied on tx, right?
Regards
Qi
> + return !((mandatory ^ requested) & supported); }
> +
> int
> i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
> uint16_t queue_idx,
> @@ -2015,6 +2029,16 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev
> *dev,
> uint16_t tx_rs_thresh, tx_free_thresh;
> uint16_t reg_idx, i, base, bsf, tc_mapping;
> int q_offset;
> + struct rte_eth_dev_info dev_info;
> +
> + if (!i40e_check_tx_queue_offloads(dev, tx_conf->offloads)) {
> + dev->dev_ops->dev_infos_get(dev, &dev_info);
> + PMD_INIT_LOG(ERR, "%p: Tx queue offloads 0x%" PRIx64
> + " don't match port offloads 0x%" PRIx64
> + " or supported offloads 0x%" PRIx64,
> + (void *)dev, tx_conf->offloads,
> + dev->data->dev_conf.txmode.offloads,
> + dev_info.tx_offload_capa); }
>
> if (hw->mac.type == I40E_MAC_VF || hw->mac.type ==
> I40E_MAC_X722_VF) {
> vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
> diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h index
> cb5f8c714..10feec4a2 100644
> --- a/drivers/net/i40e/i40e_rxtx.h
> +++ b/drivers/net/i40e/i40e_rxtx.h
> @@ -149,6 +149,7 @@ struct i40e_tx_queue {
> bool q_set; /**< indicate if tx queue has been configured */
> bool tx_deferred_start; /**< don't start this queue in dev start */
> uint8_t dcb_tc; /**< Traffic class of tx queue */
> + uint64_t offloads; /**< Tx offload flags of DEV_RX_OFFLOAD_* */
> };
>
> /** Offload features */
> --
> 2.11.0
@@ -3231,6 +3231,7 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
DEV_RX_OFFLOAD_VLAN_EXTEND |
DEV_RX_OFFLOAD_VLAN_FILTER;
+ dev_info->tx_queue_offload_capa = 0;
dev_info->tx_offload_capa =
DEV_TX_OFFLOAD_VLAN_INSERT |
DEV_TX_OFFLOAD_QINQ_INSERT |
@@ -2185,6 +2185,7 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
DEV_RX_OFFLOAD_CRC_STRIP |
DEV_RX_OFFLOAD_SCATTER;
+ dev_info->tx_queue_offload_capa = 0;
dev_info->tx_offload_capa =
DEV_TX_OFFLOAD_VLAN_INSERT |
DEV_TX_OFFLOAD_QINQ_INSERT |
@@ -1998,6 +1998,20 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
return RTE_ETH_TX_DESC_FULL;
}
+static int
+i40e_check_tx_queue_offloads(struct rte_eth_dev *dev, uint64_t requested)
+{
+ struct rte_eth_dev_info dev_info;
+ uint64_t mandatory = dev->data->dev_conf.txmode.offloads;
+ uint64_t supported; /* All per port offloads */
+
+ dev->dev_ops->dev_infos_get(dev, &dev_info);
+ supported = dev_info.tx_offload_capa ^ dev_info.tx_queue_offload_capa;
+ if ((requested & dev_info.tx_queue_offload_capa) != requested)
+ return 0; /* requested range check */
+ return !((mandatory ^ requested) & supported);
+}
+
int
i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t queue_idx,
@@ -2015,6 +2029,16 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t tx_rs_thresh, tx_free_thresh;
uint16_t reg_idx, i, base, bsf, tc_mapping;
int q_offset;
+ struct rte_eth_dev_info dev_info;
+
+ if (!i40e_check_tx_queue_offloads(dev, tx_conf->offloads)) {
+ dev->dev_ops->dev_infos_get(dev, &dev_info);
+ PMD_INIT_LOG(ERR, "%p: Tx queue offloads 0x%" PRIx64
+ " don't match port offloads 0x%" PRIx64
+ " or supported offloads 0x%" PRIx64,
+ (void *)dev, tx_conf->offloads,
+ dev->data->dev_conf.txmode.offloads,
+ dev_info.tx_offload_capa); }
if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -149,6 +149,7 @@ struct i40e_tx_queue {
bool q_set; /**< indicate if tx queue has been configured */
bool tx_deferred_start; /**< don't start this queue in dev start */
uint8_t dcb_tc; /**< Traffic class of tx queue */
+ uint64_t offloads; /**< Tx offload flags of DEV_RX_OFFLOAD_* */
};
/** Offload features */