]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/dpdk: Porting seastar's init_port_start to fix to resolve compilation errors 31840/head
authorChunsong Feng <fengchunsong@huawei.com>
Thu, 14 Nov 2019 02:10:34 +0000 (10:10 +0800)
committerluo rixin <luorixin@huawei.com>
Fri, 29 Nov 2019 10:57:47 +0000 (18:57 +0800)
Ceph currently uses dpdk19.05, seastar dpdk_device::init_port_start has
been upgraded to DPDK19.05, so porting changes to fix compiler error.

Signed-off-by: Chunsong Feng <fengchunsong@huawei.com>
src/msg/async/dpdk/DPDK.cc
src/msg/async/dpdk/DPDKStack.h

index 278efe9ed071bfbd4862308c48a00d08680b0163..79bffb074b0114a8314687750b2171fc51ba7e51 100644 (file)
@@ -151,7 +151,7 @@ static constexpr uint8_t packet_read_size        = 32;
 
 int DPDKDevice::init_port_start()
 {
-  ceph_assert(_port_idx < rte_eth_dev_count());
+  ceph_assert(_port_idx < rte_eth_dev_count_avail());
 
   rte_eth_dev_info_get(_port_idx, &_dev_info);
 
@@ -188,41 +188,35 @@ int DPDKDevice::init_port_start()
     _dev_info.max_rx_queues = std::min(_dev_info.max_rx_queues, (uint16_t)16);
   }
 
-  // Clear txq_flags - we want to support all available offload features
-  // except for multi-mempool and refcnt'ing which we don't need
-  _dev_info.default_txconf.txq_flags =
-      ETH_TXQ_FLAGS_NOMULTMEMP | ETH_TXQ_FLAGS_NOREFCOUNT;
-
-  //
-  // Disable features that are not supported by port's HW
-  //
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOXSUMUDP;
-  }
-
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOXSUMTCP;
-  }
-
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOXSUMSCTP;
-  }
-
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-  }
-
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-  }
-
-  if (!(_dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)) {
-    _dev_info.default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
-  }
+  // Hardware offload capabilities
+  // https://github.com/DPDK/dpdk/blob/v19.05/lib/librte_ethdev/rte_ethdev.h#L993-L1074
+  // We want to support all available offload features
+  // TODO: below features are implemented in 17.05, should support new ones
+  const uint64_t tx_offloads_wanted =
+    DEV_TX_OFFLOAD_VLAN_INSERT      |
+    DEV_TX_OFFLOAD_IPV4_CKSUM       |
+    DEV_TX_OFFLOAD_UDP_CKSUM        |
+    DEV_TX_OFFLOAD_TCP_CKSUM        |
+    DEV_TX_OFFLOAD_SCTP_CKSUM       |
+    DEV_TX_OFFLOAD_TCP_TSO          |
+    DEV_TX_OFFLOAD_UDP_TSO          |
+    DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+    DEV_TX_OFFLOAD_QINQ_INSERT      |
+    DEV_TX_OFFLOAD_VXLAN_TNL_TSO    |
+    DEV_TX_OFFLOAD_GRE_TNL_TSO      |
+    DEV_TX_OFFLOAD_IPIP_TNL_TSO     |
+    DEV_TX_OFFLOAD_GENEVE_TNL_TSO   |
+    DEV_TX_OFFLOAD_MACSEC_INSERT;
+
+  _dev_info.default_txconf.offloads =
+    _dev_info.tx_offload_capa & tx_offloads_wanted;
 
   /* for port configuration all features are off by default */
   rte_eth_conf port_conf = { 0 };
 
+  /* setting tx offloads for port */
+  port_conf.txmode.offloads = _dev_info.default_txconf.offloads;
+
   ldout(cct, 5) << __func__ << " Port " << int(_port_idx) << ": max_rx_queues "
                 << _dev_info.max_rx_queues << "  max_tx_queues "
                 << _dev_info.max_tx_queues << dendl;
@@ -230,7 +224,7 @@ int DPDKDevice::init_port_start()
   _num_queues = std::min({_num_queues, _dev_info.max_rx_queues, _dev_info.max_tx_queues});
 
   ldout(cct, 5) << __func__ << " Port " << int(_port_idx) << ": using "
-                << _num_queues << " queues" << dendl;;
+                << _num_queues << " queues" << dendl;
 
   // Set RSS mode: enable RSS if seastar is configured with more than 1 CPU.
   // Even if port has a single queue we still want the RSS feature to be
@@ -251,7 +245,8 @@ int DPDKDevice::init_port_start()
     }
 
     port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-    port_conf.rx_adv_conf.rss_conf.rss_hf = ETH_RSS_PROTO_MASK;
+    /* enable all supported rss offloads */
+    port_conf.rx_adv_conf.rss_conf.rss_hf = _dev_info.flow_type_rss_offloads;
     if (_dev_info.hash_key_size) {
       port_conf.rx_adv_conf.rss_conf.rss_key = const_cast<uint8_t *>(_rss_key.data());
       port_conf.rx_adv_conf.rss_conf.rss_key_len = _dev_info.hash_key_size;
@@ -281,17 +276,14 @@ int DPDKDevice::init_port_start()
 
   // Set Rx VLAN stripping
   if (_dev_info.rx_offload_capa & DEV_RX_OFFLOAD_VLAN_STRIP) {
-    port_conf.rxmode.hw_vlan_strip = 1;
+    port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
   }
 
-  // Enable HW CRC stripping
-  port_conf.rxmode.hw_strip_crc = 1;
-
 #ifdef RTE_ETHDEV_HAS_LRO_SUPPORT
   // Enable LRO
   if (_use_lro && (_dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_LRO)) {
     ldout(cct, 1) << __func__ << " LRO is on" << dendl;
-    port_conf.rxmode.enable_lro = 1;
+    port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TCP_LRO;
     _hw_features.rx_lro = true;
   } else
 #endif
@@ -310,7 +302,7 @@ int DPDKDevice::init_port_start()
   if ((_dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM) &&
       (_dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)) {
     ldout(cct, 1) << __func__ << " RX checksum offload supported" << dendl;
-    port_conf.rxmode.hw_ip_checksum = 1;
+    port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_CHECKSUM;
     _hw_features.rx_csum_offload = 1;
   }
 
@@ -1256,10 +1248,10 @@ std::unique_ptr<DPDKDevice> create_dpdk_net_device(
     bool enable_fc)
 {
   // Check that we have at least one DPDK-able port
-  if (rte_eth_dev_count() == 0) {
+  if (rte_eth_dev_count_avail() == 0) {
     rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
   } else {
-    ldout(cct, 10) << __func__ << " ports number: " << int(rte_eth_dev_count()) << dendl;
+    ldout(cct, 10) << __func__ << " ports number: " << int(rte_eth_dev_count_avail()) << dendl;
   }
 
   return std::unique_ptr<DPDKDevice>(
index e41a87545220ee81fbd4de4d1c5f19f372646dd6..2642b9d96a9520db82b90e2f23371adfa9f647f7 100644 (file)
@@ -135,7 +135,7 @@ class NativeConnectedSocketImpl : public ConnectedSocketImpl {
     }
 
     std::vector<fragment> frags;
-    std::list<bufferptr>::const_iterator pb = bl.buffers().begin();
+    auto pb = bl.buffers().begin();
     uint64_t left_pbrs = bl.buffers().size();
     uint64_t len = 0;
     uint64_t seglen = 0;