Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to DPDK 23.11 #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.so
*.o
build/
.history
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RUN git clone -b 'stable-v40' --single-branch --depth 1 https://github.com/linux
ENV RTE_SDK /root/dpdk

# Build DPDK
RUN git clone --depth 1 --branch 'v21.11' https://github.com/DPDK/dpdk.git ${RTE_SDK} && \
RUN git clone --depth 1 --branch 'v23.11' https://github.com/DPDK/dpdk.git ${RTE_SDK} && \
cd ${RTE_SDK} && \
meson build -Dexamples='' -Dplatform=generic -Denable_kmods=false -Dtests=false -Ddisable_drivers='raw/*,crypto/*,baseband/*,dma/*' && \
cd build/ && \
Expand Down
4 changes: 2 additions & 2 deletions docs/INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ ldconfig

### Build DPDK

We use DPDK v21.11 LTS, like so:
We use DPDK v23.11 LTS, like so:

```bash
export RTE_SDK=/path/to/dpdk-21.11/
export RTE_SDK=/path/to/dpdk-23.11/
cd ${RTE_SDK} && meson build && cd build && ninja && DESTDIR=${PWD}/install ninja install
```

Expand Down
33 changes: 15 additions & 18 deletions src/core/drivers/dpdk/pmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __attribute__((unused)) static void ReportLinkStatus(uint8_t port_id) {
LOG(WARNING) << "rte_eth_link_get_nowait() failed.";
}

if (link.link_status == ETH_LINK_UP) {
if (link.link_status == RTE_ETH_LINK_UP) {
LOG(INFO) << "[PMDPORT: " << static_cast<int>(port_id) << "] "
<< "Link is UP " << link.link_speed
<< (link.link_autoneg ? "(AutoNeg)" : "(Fixed)")
Expand All @@ -38,18 +38,17 @@ static rte_eth_conf DefaultEthConf(const rte_eth_dev_info *devinfo) {
// offloads so return a very basic ethernet configuration.
if (std::string(devinfo->driver_name) == "net_null") return port_conf;

port_conf.link_speeds = ETH_LINK_SPEED_AUTONEG;
uint64_t rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP | ETH_RSS_SCTP;
port_conf.link_speeds = RTE_ETH_LINK_SPEED_AUTONEG;
uint64_t rss_hf = RTE_ETH_RSS_IP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_TCP | RTE_ETH_RSS_SCTP;
if (devinfo->flow_type_rss_offloads) {
rss_hf &= devinfo->flow_type_rss_offloads;
}

port_conf.lpbk_mode = 1;
port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
port_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_RSS;

port_conf.rxmode.mtu = PmdRing::kDefaultFrameSize;
port_conf.rxmode.max_lro_pkt_size = PmdRing::kDefaultFrameSize;
port_conf.rxmode.split_hdr_size = 0;
const auto rx_offload_capa = devinfo->rx_offload_capa;
port_conf.rxmode.offloads |= ((RTE_ETH_RX_OFFLOAD_CHECKSUM)&rx_offload_capa);

Expand All @@ -60,21 +59,21 @@ static rte_eth_conf DefaultEthConf(const rte_eth_dev_info *devinfo) {
};

const auto tx_offload_capa = devinfo->tx_offload_capa;
if (!(tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) ||
!(tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM)) {
if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ||
!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
// Making this fatal; not sure what NIC does not support checksum offloads.
LOG(FATAL) << "Hardware does not support checksum offloads.";
}

port_conf.txmode.mq_mode = ETH_MQ_TX_NONE;
port_conf.txmode.mq_mode = RTE_ETH_MQ_TX_NONE;
port_conf.txmode.offloads =
(DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM);
(RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM);

if (tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) {
if (tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
// TODO(ilias): Add option to the constructor to enable this offload.
LOG(WARNING)
<< "Enabling FAST FREE: use always the same mempool for each queue.";
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
}

return port_conf;
Expand All @@ -100,7 +99,7 @@ void RxRing::Init() {
void PmdPort::InitDriver(uint16_t mtu) {
if (is_dpdk_primary_process_) {
// Get DPDK port info.
FetchDpdkPortInfo(port_id_, &devinfo_, &l2_addr_, &pci_info_);
FetchDpdkPortInfo(port_id_, &devinfo_, &l2_addr_);
device_ = devinfo_.device;

if (std::string(devinfo_.driver_name) == "net_netvsc") {
Expand All @@ -115,9 +114,7 @@ void PmdPort::InitDriver(uint16_t mtu) {
// Get DPDK port info.
struct rte_eth_dev_info vf_devinfo_;
struct net::Ethernet::Address vf_l2_addr_;
std::string vf_pci_info_;
FetchDpdkPortInfo(vf_port_id.value(), &vf_devinfo_, &vf_l2_addr_,
&vf_pci_info_);
FetchDpdkPortInfo(vf_port_id.value(), &vf_devinfo_, &vf_l2_addr_);

// If the VF is using an 'mlx4*' driver, we need extra checks.
if (std::string(vf_devinfo_.driver_name).find("mlx4") !=
Expand Down Expand Up @@ -282,7 +279,7 @@ void PmdPort::InitDriver(uint16_t mtu) {
struct rte_eth_link link;
memset(&link, '0', sizeof(link));
int nsecs = 30;
while (nsecs-- && link.link_status == ETH_LINK_DOWN) {
while (nsecs-- && link.link_status == RTE_ETH_LINK_DOWN) {
memset(&link, '0', sizeof(link));
int ret = rte_eth_link_get_nowait(port_id_, &link);
if (ret != 0) {
Expand All @@ -292,7 +289,7 @@ void PmdPort::InitDriver(uint16_t mtu) {
sleep(1);
}

if (link.link_status == ETH_LINK_UP) {
if (link.link_status == RTE_ETH_LINK_UP) {
LOG(INFO) << "[PMDPORT: " << static_cast<int>(port_id_) << "] "
<< "Link is UP " << link.link_speed
<< (link.link_autoneg ? " (AutoNeg)" : " (Fixed)")
Expand All @@ -302,7 +299,7 @@ void PmdPort::InitDriver(uint16_t mtu) {
<< "Link is DOWN.";
}
} else {
FetchDpdkPortInfo(port_id_, &devinfo_, &l2_addr_, &pci_info_);
FetchDpdkPortInfo(port_id_, &devinfo_, &l2_addr_);

// For the rings, just set port and queue IDs here, which have been
// pre-initialized by the DPDK primary process
Expand Down
1 change: 1 addition & 0 deletions src/include/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <machnet_private.h>
#include <rte_eal.h>
#include <rte_mbuf_core.h>
#include <rte_dev.h>

#include <iterator>
#include <list>
Expand Down
25 changes: 7 additions & 18 deletions src/include/dpdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <packet_pool.h>
#include <rte_bus_pci.h>
#include <rte_ethdev.h>
#include <rte_ether.h>

#include <utils.h>
#include <worker.h>

Expand All @@ -18,7 +18,8 @@ namespace dpdk {

[[maybe_unused]] static void FetchDpdkPortInfo(
uint8_t port_id, struct rte_eth_dev_info *devinfo,
juggler::net::Ethernet::Address *lladdr, std::string *pci_string) {
juggler::net::Ethernet::Address *lladdr) {

if (!rte_eth_dev_is_valid_port(port_id)) {
LOG(INFO) << "Port id " << static_cast<int>(port_id) << " is not valid.";
return;
Expand All @@ -36,21 +37,11 @@ namespace dpdk {
rte_eth_macaddr_get(port_id,
reinterpret_cast<rte_ether_addr *>(lladdr->bytes));

struct rte_bus *bus = rte_bus_find_by_device(devinfo->device);
if (bus && !strcmp(bus->name, "pci")) {
const struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(devinfo->device);
*pci_string = juggler::utils::Format(
"%08x:%02hhx:%02hhx.%02hhx %04hx:%04hx", pci_dev->addr.domain,
pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function,
pci_dev->id.vendor_id, pci_dev->id.device_id);
}

LOG(INFO) << "[PMDPORT] [port_id: " << static_cast<uint32_t>(port_id)
<< ", driver: " << devinfo->driver_name
<< ", RXQ: " << devinfo->max_rx_queues
<< ", TXQ: " << devinfo->max_tx_queues
<< ", l2addr: " << lladdr->ToString()
<< ", pci_info: " << *pci_string << "]";
<< ", l2addr: " << lladdr->ToString() << "]";
}

[[maybe_unused]] static std::optional<uint16_t> FindSlaveVfPortId(
Expand All @@ -59,7 +50,7 @@ namespace dpdk {
std::string pci_info;
juggler::net::Ethernet::Address lladdr;

FetchDpdkPortInfo(port_id, &devinfo, &lladdr, &pci_info);
FetchDpdkPortInfo(port_id, &devinfo, &lladdr);

uint16_t slave_port_id = 0;
while (slave_port_id < RTE_MAX_ETHPORTS) {
Expand All @@ -73,10 +64,8 @@ namespace dpdk {
}

struct rte_eth_dev_info slave_devinfo;
std::string slave_pci_info;
juggler::net::Ethernet::Address slave_lladdr;
FetchDpdkPortInfo(slave_port_id, &slave_devinfo, &slave_lladdr,
&slave_pci_info);
FetchDpdkPortInfo(slave_port_id, &slave_devinfo, &slave_lladdr);
if (slave_lladdr == lladdr) {
return slave_port_id;
}
Expand All @@ -97,7 +86,7 @@ namespace dpdk {
std::string pci_info;
juggler::net::Ethernet::Address lladdr;

FetchDpdkPortInfo(port_id, &devinfo, &lladdr, &pci_info);
FetchDpdkPortInfo(port_id, &devinfo, &lladdr);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/include/pmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ class PmdPort {
std::vector<rte_eth_rss_reta_entry64> rss_reta_conf_;
struct rte_eth_stats port_stats_;
std::vector<uint8_t> rss_hash_key_;
std::string pci_info_;
bool initialized_;
};
} // namespace dpdk
Expand Down
Loading