A new offloads API was introduced by commits: commit 121fff673172 ("ethdev: introduce Rx queue offloads API") commit 35ac80d92f29 ("ethdev: introduce Tx queue offloads API")
In order to enable the PMDs to support only one of the APIs, a conversion functions from the old to new API were added. Signed-off-by: Shahaf Shuler <shah...@mellanox.com> --- lib/librte_ether/rte_ethdev.c | 99 +++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 50f8aa98d..1aa21a129 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1006,6 +1006,34 @@ rte_eth_dev_close(uint8_t port_id) dev->data->tx_queues = NULL; } +/** + * A conversion function from rxmode offloads API to rte_eth_rxq_conf + * offloads API. + */ +static void +rte_eth_convert_rxmode_offloads(struct rte_eth_rxmode *rxmode, + struct rte_eth_rxq_conf *rxq_conf) +{ + if (rxmode->header_split == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_HEADER_SPLIT; + if (rxmode->hw_ip_checksum == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_CHECKSUM; + if (rxmode->hw_vlan_filter == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; + if (rxmode->hw_vlan_strip == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + if (rxmode->hw_vlan_extend == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; + if (rxmode->jumbo_frame == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + if (rxmode->hw_strip_crc == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_CRC_STRIP; + if (rxmode->enable_scatter == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_SCATTER; + if (rxmode->enable_lro == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_TCP_LRO; +} + int rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, @@ -1016,6 +1044,8 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, uint32_t mbp_buf_size; struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + struct rte_eth_rxq_conf rxq_trans_conf; + /* Holds translated configuration to be passed to the PMD */ void **rxq; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); @@ -1062,6 +1092,11 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, return -EINVAL; } + if ((!(dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD)) && + (dev->data->dev_conf.rxmode.ignore_offloads == 1)) { + return -ENOTSUP; + } + if (nb_rx_desc > dev_info.rx_desc_lim.nb_max || nb_rx_desc < dev_info.rx_desc_lim.nb_min || nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) { @@ -1086,8 +1121,15 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, if (rx_conf == NULL) rx_conf = &dev_info.default_rxconf; + rxq_trans_conf = *rx_conf; + if ((dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD) && + (dev->data->dev_conf.rxmode.ignore_offloads == 0)) { + rte_eth_convert_rxmode_offloads(&dev->data->dev_conf.rxmode, + &rxq_trans_conf); + } + ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, - socket_id, rx_conf, mp); + socket_id, &rxq_trans_conf, mp); if (!ret) { if (!dev->data->min_rx_buf_size || dev->data->min_rx_buf_size > mbp_buf_size) @@ -1097,6 +1139,49 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, return ret; } +/** + * A conversion function from txq_flags to rte_eth_txq_conf offloads API. + */ +static void +rte_eth_convert_txq_flags(struct rte_eth_txq_conf *txq_conf) +{ + uint32_t txq_flags = txq_conf->txq_flags; + uint64_t *offloads = &txq_conf->offloads; + + if (!(txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS)) + *offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; + if (!(txq_flags & ETH_TXQ_FLAGS_NOVLANOFFL)) + *offloads |= DEV_TX_OFFLOAD_VLAN_INSERT; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP)) + *offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMUDP)) + *offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMTCP)) + *offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; +} + +/** + * A conversion function between rte_eth_txq_conf offloads API to txq_flags + * offloads API. + */ +static void +rte_eth_convert_txq_offloads(struct rte_eth_txq_conf *txq_conf) +{ + uint32_t *txq_flags = &txq_conf->txq_flags; + uint64_t offloads = txq_conf->offloads; + + if (!(offloads & DEV_TX_OFFLOAD_MULTI_SEGS)) + *txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS; + if (!(offloads & DEV_TX_OFFLOAD_VLAN_INSERT)) + *txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL; + if (!(offloads & DEV_TX_OFFLOAD_SCTP_CKSUM)) + *txq_flags |= ETH_TXQ_FLAGS_NOXSUMSCTP; + if (!(offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) + *txq_flags |= ETH_TXQ_FLAGS_NOXSUMUDP; + if (!(offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) + *txq_flags |= ETH_TXQ_FLAGS_NOXSUMTCP; +} + int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, uint16_t nb_tx_desc, unsigned int socket_id, @@ -1104,6 +1189,8 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, { struct rte_eth_dev *dev; struct rte_eth_dev_info dev_info; + struct rte_eth_txq_conf txq_trans_conf; + /* Holds translated configuration to be passed to the PMD */ void **txq; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); @@ -1148,8 +1235,16 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, if (tx_conf == NULL) tx_conf = &dev_info.default_txconf; + txq_trans_conf = *tx_conf; + if ((dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && + (!(tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE))) + rte_eth_convert_txq_flags(&txq_trans_conf); + else if (!(dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && + (tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE)) + rte_eth_convert_txq_offloads(&txq_trans_conf); + return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc, - socket_id, tx_conf); + socket_id, &txq_trans_conf); } void -- 2.12.0