Add the support of UDP fragmentation offload feature.

Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Long Wu <long...@corigine.com>
Reviewed-by: Peng Zhang <peng.zh...@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h | 1 +
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c   | 7 ++++++-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c   | 8 +++++---
 drivers/net/nfp/nfp_net_common.c     | 8 ++++++--
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h 
b/drivers/common/nfp/nfp_common_ctrl.h
index d65fcd17cb..93722bc350 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -226,6 +226,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_MULTI_PF         (0x1 << 5)
 #define NFP_NET_CFG_CTRL_FLOW_STEER       (0x1 << 8) /**< Flow Steering */
 #define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order 
flag */
+#define NFP_NET_CFG_CTRL_USO              (0x1 << 16) /**< UDP segmentation 
offload */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
 
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c 
b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index fbc2dbedf4..ee120f55ab 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -34,7 +34,8 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
                goto clean_txd;
 
        ol_flags = mb->ol_flags;
-       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0)
+       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0 &&
+                       (ol_flags & RTE_MBUF_F_TX_UDP_SEG) == 0)
                goto clean_txd;
 
        txd->l3_offset = mb->l2_len;
@@ -78,6 +79,10 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq,
        if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
                txd->flags |= NFD3_DESC_TX_TCP_CSUM;
 
+       /* Set UDP csum offload if UFO enabled. */
+       if ((ol_flags & RTE_MBUF_F_TX_UDP_SEG) != 0)
+               txd->flags |= NFD3_DESC_TX_UDP_CSUM;
+
        /* IPv6 does not need checksum */
        if ((ol_flags & RTE_MBUF_F_TX_IP_CKSUM) != 0)
                txd->flags |= NFD3_DESC_TX_IP4_CSUM;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c 
b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 72efbffb42..a1c6ecdfe5 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -28,8 +28,9 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq,
 
        ol_flags = mb->ol_flags;
 
-       /* Set TCP csum offload if TSO enabled. */
-       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
+       /* Set L4 csum offload if TSO/UFO enabled. */
+       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0 ||
+                       (ol_flags & RTE_MBUF_F_TX_UDP_SEG) != 0)
                flags |= NFDK_DESC_TX_L4_CSUM;
 
        if ((ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) != 0)
@@ -61,7 +62,8 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
                return txd.raw;
 
        ol_flags = mb->ol_flags;
-       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0)
+       if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0 &&
+                       (ol_flags & RTE_MBUF_F_TX_UDP_SEG) == 0)
                return txd.raw;
 
        txd.l3_offset = mb->l2_len;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 72c9a41b00..99c319eb2d 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -312,7 +312,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
                        hw->ver.major, hw->ver.minor, hw->max_mtu);
 
        PMD_INIT_LOG(INFO, "CAP: %#x", cap);
-       PMD_INIT_LOG(INFO, 
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+       PMD_INIT_LOG(INFO, 
"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                        cap & NFP_NET_CFG_CTRL_ENABLE        ? "ENABLE "      : 
"",
                        cap & NFP_NET_CFG_CTRL_PROMISC       ? "PROMISC "     : 
"",
                        cap & NFP_NET_CFG_CTRL_L2BC          ? "L2BCFILT "    : 
"",
@@ -340,7 +340,8 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
                        cap & NFP_NET_CFG_CTRL_LSO2          ? "TSOv2 "       : 
"",
                        cap & NFP_NET_CFG_CTRL_RSS2          ? "RSSv2 "       : 
"",
                        cap & NFP_NET_CFG_CTRL_CSUM_COMPLETE ? "CSUM "        : 
"",
-                       cap & NFP_NET_CFG_CTRL_LIVE_ADDR     ? "LIVE_ADDR "   : 
"");
+                       cap & NFP_NET_CFG_CTRL_LIVE_ADDR     ? "LIVE_ADDR "   : 
"",
+                       cap & NFP_NET_CFG_CTRL_USO           ? "USO"          : 
"");
 
        PMD_INIT_LOG(INFO, "CAP_WORD1: %#x", cap_ext);
        PMD_INIT_LOG(INFO, "%s%s%s%s%s%s%s",
@@ -537,6 +538,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 
        /* LSO offload */
        if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
+                       (tx_offload & RTE_ETH_TX_OFFLOAD_UDP_TSO) != 0 ||
                        (tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
                if ((cap & NFP_NET_CFG_CTRL_LSO) != 0)
                        ctrl |= NFP_NET_CFG_CTRL_LSO;
@@ -1214,6 +1216,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
 
        if ((cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
                dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+               if ((cap & NFP_NET_CFG_CTRL_USO) != 0)
+                       dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_UDP_TSO;
                if ((cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
                        dev_info->tx_offload_capa |= 
RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
        }
-- 
2.39.1

Reply via email to