net/nfp: implement the burst mode get operation
Checks
Commit Message
Implement the burst mode get operation functions for both Rx and Tx.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 2 ++
drivers/net/nfp/nfp_ethdev_vf.c | 2 ++
drivers/net/nfp/nfp_rxtx.c | 46 +++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_rxtx.h | 4 +++
4 files changed, 54 insertions(+)
Comments
On Wed, 18 Dec 2024 14:30:36 +0800
Chaoyong He <chaoyong.he@corigine.com> wrote:
> +int
> +nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev,
> + uint16_t queue_id __rte_unused,
> + struct rte_eth_burst_mode *mode)
> +{
> + eth_rx_burst_t pkt_burst;
> +
> + pkt_burst = eth_dev->rx_pkt_burst;
> + if (pkt_burst == nfp_net_recv_pkts) {
> + snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
> + "Scalar");
> + } else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
> + snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
> + "Vector AVX2");
> + } else {
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
The coccinelle script want to replace that snprintf with strlcpy
Also don't need {} for one line statement but its ok as is.
> On Wed, 18 Dec 2024 14:30:36 +0800
> Chaoyong He <chaoyong.he@corigine.com> wrote:
>
> > +int
> > +nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev,
> > + uint16_t queue_id __rte_unused,
> > + struct rte_eth_burst_mode *mode)
> > +{
> > + eth_rx_burst_t pkt_burst;
> > +
> > + pkt_burst = eth_dev->rx_pkt_burst;
> > + if (pkt_burst == nfp_net_recv_pkts) {
> > + snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE,
> "%s",
> > + "Scalar");
> > + } else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
> > + snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE,
> "%s",
> > + "Vector AVX2");
> > + } else {
> > + return -EINVAL;
> > + }
> > +
> > + return 0;
> > +}
> > +
>
> The coccinelle script want to replace that snprintf with strlcpy
>
> Also don't need {} for one line statement but its ok as is.
Okay, I will send a new version patch.
@@ -985,6 +985,8 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
.get_module_eeprom = nfp_net_get_module_eeprom,
.dev_led_on = nfp_net_led_on,
.dev_led_off = nfp_net_led_off,
+ .rx_burst_mode_get = nfp_net_rx_burst_mode_get,
+ .tx_burst_mode_get = nfp_net_tx_burst_mode_get,
};
static inline void
@@ -232,6 +232,8 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
.tx_queue_release = nfp_net_tx_queue_release,
.rx_queue_intr_enable = nfp_rx_queue_intr_enable,
.rx_queue_intr_disable = nfp_rx_queue_intr_disable,
+ .rx_burst_mode_get = nfp_net_rx_burst_mode_get,
+ .tx_burst_mode_get = nfp_net_tx_burst_mode_get,
};
static inline void
@@ -12,6 +12,7 @@
#include "nfd3/nfp_nfd3.h"
#include "nfdk/nfp_nfdk.h"
+#include "nfdk/nfp_nfdk_vec.h"
#include "flower/nfp_flower.h"
#include "nfp_ipsec.h"
@@ -893,3 +894,48 @@ nfp_net_recv_pkts_set(struct rte_eth_dev *eth_dev)
else
eth_dev->rx_pkt_burst = nfp_net_recv_pkts;
}
+
+int
+nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev,
+ uint16_t queue_id __rte_unused,
+ struct rte_eth_burst_mode *mode)
+{
+ eth_rx_burst_t pkt_burst;
+
+ pkt_burst = eth_dev->rx_pkt_burst;
+ if (pkt_burst == nfp_net_recv_pkts) {
+ snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+ "Scalar");
+ } else if (pkt_burst == nfp_net_vec_avx2_recv_pkts) {
+ snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+ "Vector AVX2");
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int
+nfp_net_tx_burst_mode_get(struct rte_eth_dev *eth_dev,
+ uint16_t queue_id __rte_unused,
+ struct rte_eth_burst_mode *mode)
+{
+ eth_tx_burst_t pkt_burst;
+
+ pkt_burst = eth_dev->tx_pkt_burst;
+ if (pkt_burst == nfp_net_nfd3_xmit_pkts) {
+ snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+ "NFD3 Scalar");
+ } else if (pkt_burst == nfp_net_nfdk_xmit_pkts) {
+ snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+ "NFDk Scalar");
+ } else if (pkt_burst == nfp_net_nfdk_vec_avx2_xmit_pkts) {
+ snprintf(mode->info, RTE_ETH_BURST_MODE_INFO_SIZE, "%s",
+ "NFDk Vector AVX2");
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+}
@@ -245,6 +245,10 @@ void nfp_net_tx_queue_info_get(struct rte_eth_dev *dev,
uint16_t queue_id,
struct rte_eth_txq_info *qinfo);
void nfp_net_recv_pkts_set(struct rte_eth_dev *eth_dev);
+int nfp_net_rx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode);
+int nfp_net_tx_burst_mode_get(struct rte_eth_dev *eth_dev, uint16_t queue_id,
+ struct rte_eth_burst_mode *mode);
void nfp_net_parse_ptype(struct nfp_net_rxq *rxq,
struct nfp_net_rx_desc *rxds,
struct rte_mbuf *mb);