replace snprintf with strlcpy
[dpdk.git] / drivers / net / ice / ice_ethdev.c
index c1c1efc..a06ebda 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#include <rte_string_fns.h>
 #include <rte_ethdev_pci.h>
 
 #include <stdio.h>
@@ -10,6 +11,7 @@
 #include <unistd.h>
 
 #include "base/ice_sched.h"
+#include "base/ice_flow.h"
 #include "ice_ethdev.h"
 #include "ice_rxtx.h"
 
@@ -1634,6 +1636,44 @@ static int ice_init_rss(struct ice_pf *pf)
        if (ret)
                return -EINVAL;
 
+       /* configure RSS for tcp6 with input set IPv6 src/dst, TCP src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV6,
+                             ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s TCP_IPV6 rss flow fail %d", __func__, ret);
+
+       /* configure RSS for udp6 with input set IPv6 src/dst, UDP src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV6,
+                             ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s UDP_IPV6 rss flow fail %d", __func__, ret);
+
+       /* configure RSS for sctp6 with input set IPv6 src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_FLOW_HASH_IPV6,
+                             ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV6);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s SCTP_IPV6 rss flow fail %d",
+                               __func__, ret);
+
+       /* configure RSS for tcp4 with input set IP src/dst, TCP src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_TCP_IPV4,
+                             ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s TCP_IPV4 rss flow fail %d", __func__, ret);
+
+       /* configure RSS for udp4 with input set IP src/dst, UDP src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_HASH_UDP_IPV4,
+                             ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s UDP_IPV4 rss flow fail %d", __func__, ret);
+
+       /* configure RSS for sctp4 with input set IP src/dst */
+       ret = ice_add_rss_cfg(hw, vsi->idx, ICE_FLOW_HASH_IPV4,
+                             ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV4);
+       if (ret)
+               PMD_DRV_LOG(ERR, "%s SCTP_IPV4 rss flow fail %d",
+                               __func__, ret);
+
        return 0;
 }
 
@@ -1907,6 +1947,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        struct ice_vsi *vsi = pf->main_vsi;
        struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device);
        bool is_safe_mode = pf->adapter->is_safe_mode;
+       u64 phy_type_low;
+       u64 phy_type_high;
 
        dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN;
        dev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX;
@@ -1993,10 +2035,17 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
                               ETH_LINK_SPEED_5G |
                               ETH_LINK_SPEED_10G |
                               ETH_LINK_SPEED_20G |
-                              ETH_LINK_SPEED_25G |
-                              ETH_LINK_SPEED_40G |
-                              ETH_LINK_SPEED_50G |
-                              ETH_LINK_SPEED_100G;
+                              ETH_LINK_SPEED_25G;
+
+       phy_type_low = hw->port_info->phy.phy_type_low;
+       phy_type_high = hw->port_info->phy.phy_type_high;
+
+       if (ICE_PHY_TYPE_SUPPORT_50G(phy_type_low))
+               dev_info->speed_capa |= ETH_LINK_SPEED_50G;
+
+       if (ICE_PHY_TYPE_SUPPORT_100G_LOW(phy_type_low) ||
+                       ICE_PHY_TYPE_SUPPORT_100G_HIGH(phy_type_high))
+               dev_info->speed_capa |= ETH_LINK_SPEED_100G;
 
        dev_info->nb_rx_queues = dev->data->nb_rx_queues;
        dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -3389,17 +3438,15 @@ static int ice_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 
        /* Get stats from ice_eth_stats struct */
        for (i = 0; i < ICE_NB_ETH_XSTATS; i++) {
-               snprintf(xstats_names[count].name,
-                        sizeof(xstats_names[count].name),
-                        "%s", ice_stats_strings[i].name);
+               strlcpy(xstats_names[count].name, ice_stats_strings[i].name,
+                       sizeof(xstats_names[count].name));
                count++;
        }
 
        /* Get individiual stats from ice_hw_port struct */
        for (i = 0; i < ICE_NB_HW_PORT_XSTATS; i++) {
-               snprintf(xstats_names[count].name,
-                        sizeof(xstats_names[count].name),
-                        "%s", ice_hw_port_strings[i].name);
+               strlcpy(xstats_names[count].name, ice_hw_port_strings[i].name,
+                       sizeof(xstats_names[count].name));
                count++;
        }