Skip to content

Commit

Permalink
Merge pull request #680 from AltraMayor/upgrd_dpdk
Browse files Browse the repository at this point in the history
gatekeeper: upgrade DPDK to version 23.11
  • Loading branch information
AltraMayor authored Mar 25, 2024
2 parents 2b9f00b + caf646c commit 9b648f7
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "dependencies/dpdk"]
path = dependencies/dpdk
url = https://github.com/cjdoucette/dpdk
branch = gkv1.2b
branch = gkv1.2c
[submodule "dependencies/luajit-2.0"]
path = dependencies/luajit-2.0
url = https://github.com/AltraMayor/luajit.git
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ above. Gatekeeper and the submodules will be automatically compiled during the
package build process.

```console
$ tar --exclude-vcs -Jcvf ../gatekeeper_1.1.0.orig.tar.xz -C .. gatekeeper
$ tar --exclude-vcs -Jcvf ../gatekeeper_1.2.0.orig.tar.xz -C .. gatekeeper
$ debuild -uc -us
```

Expand Down
2 changes: 1 addition & 1 deletion bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ copy: all
$(INSTALL) -m660 $(TARGETS) $(DESTDIR)

%.bpf: %.c
$(CC) $(CFLAGS) -o $@ -c $^
$(CC) $(CFLAGS) -o $@ -D RTE_FORCE_INTRINSICS -c $^

PHONY: cscope clean

Expand Down
33 changes: 6 additions & 27 deletions cps/kni.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@
#include "gatekeeper_main.h"
#include "kni.h"

/*
* XXX #677 Adopt RTE_ETHER_ADDR_PRT_FMT and RTE_ETHER_ADDR_BYTES
* once DPDK is updated.
*/
/**
* Macro to print six-bytes of MAC address in hex format
*/
#define RTE_ETHER_ADDR_PRT_FMT "%02X:%02X:%02X:%02X:%02X:%02X"
/**
* Macro to extract the MAC address bytes from rte_ether_addr struct
*/
#define RTE_ETHER_ADDR_BYTES(mac_addrs) ((mac_addrs)->addr_bytes[0]), \
((mac_addrs)->addr_bytes[1]), \
((mac_addrs)->addr_bytes[2]), \
((mac_addrs)->addr_bytes[3]), \
((mac_addrs)->addr_bytes[4]), \
((mac_addrs)->addr_bytes[5])

#define KNI_BUS_NAME "vdev"

void
Expand All @@ -62,7 +44,12 @@ static int
setup_dpdk_interface(struct cps_kni *kni, const struct gatekeeper_if *iface,
struct rte_mempool *mp, uint16_t queue_size)
{
struct rte_eth_conf port_conf = {};
struct rte_eth_conf port_conf = {
.rxmode = {
.mtu = iface->mtu,
.offloads = RTE_ETH_RX_OFFLOAD_SCATTER,
},
};

int ret = rte_eth_dev_get_port_by_name(kni->cps_name, &kni->cps_portid);
if (unlikely(ret < 0)) {
Expand All @@ -73,14 +60,6 @@ setup_dpdk_interface(struct cps_kni *kni, const struct gatekeeper_if *iface,
return ret;
}

ret = rte_eth_dev_set_mtu(kni->cps_portid, iface->mtu);
if (unlikely(ret < 0)) {
G_LOG(ERR, "%s(%s): cannot set the MTU=%u (errno=%i): %s\n",
__func__, iface->name, iface->mtu,
-ret, rte_strerror(-ret));
return ret;
}

ret = rte_eth_dev_configure(kni->cps_portid, 1, 1, &port_conf);
if (unlikely(ret < 0)) {
G_LOG(ERR, "%s(%s): failed to configure port (errno=%i): %s\n",
Expand Down
8 changes: 4 additions & 4 deletions cps/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ send_arp_reply_kni(struct cps_config *cps_conf, struct cps_arp_req *arp)
* the Ethernet and ARP headers.
*/
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
rte_ether_addr_copy(&arp->ha, &eth_hdr->s_addr);
rte_ether_addr_copy(&iface->eth_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&iface->eth_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&arp->ha, &eth_hdr->src_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);

/* Set-up ARP header. */
Expand Down Expand Up @@ -177,8 +177,8 @@ send_nd_reply_kni(struct cps_config *cps_conf, struct cps_nd_req *nd)
* the Ethernet header.
*/
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
rte_ether_addr_copy(&nd->ha, &eth_hdr->s_addr);
rte_ether_addr_copy(&iface->eth_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&iface->eth_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&nd->ha, &eth_hdr->src_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);

/* Set-up IPv6 header. */
Expand Down
2 changes: 1 addition & 1 deletion dependencies/dpdk
Submodule dpdk updated 5170 files
16 changes: 8 additions & 8 deletions gk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,9 +1144,9 @@ xmit_icmp(struct gatekeeper_if *iface, struct ipacket *packet,
}
}

rte_ether_addr_copy(&icmp_eth->s_addr, &eth_addr_tmp);
rte_ether_addr_copy(&icmp_eth->d_addr, &icmp_eth->s_addr);
rte_ether_addr_copy(&eth_addr_tmp, &icmp_eth->d_addr);
rte_ether_addr_copy(&icmp_eth->src_addr, &eth_addr_tmp);
rte_ether_addr_copy(&icmp_eth->dst_addr, &icmp_eth->src_addr);
rte_ether_addr_copy(&eth_addr_tmp, &icmp_eth->dst_addr);
if (iface->vlan_insert) {
fill_vlan_hdr(icmp_eth, iface->ipv4_vlan_tag_be,
RTE_ETHER_TYPE_IPV4);
Expand Down Expand Up @@ -1217,9 +1217,9 @@ xmit_icmpv6(struct gatekeeper_if *iface, struct ipacket *packet,
}
}

rte_ether_addr_copy(&icmp_eth->s_addr, &eth_addr_tmp);
rte_ether_addr_copy(&icmp_eth->d_addr, &icmp_eth->s_addr);
rte_ether_addr_copy(&eth_addr_tmp, &icmp_eth->d_addr);
rte_ether_addr_copy(&icmp_eth->src_addr, &eth_addr_tmp);
rte_ether_addr_copy(&icmp_eth->dst_addr, &icmp_eth->src_addr);
rte_ether_addr_copy(&eth_addr_tmp, &icmp_eth->dst_addr);
if (iface->vlan_insert) {
fill_vlan_hdr(icmp_eth, iface->ipv6_vlan_tag_be,
RTE_ETHER_TYPE_IPV6);
Expand Down Expand Up @@ -2739,8 +2739,8 @@ get_responsible_gk_mailbox(uint32_t flow_hash_val,
* Identify which GK block is responsible for the
* pair <Src, Dst> in the decision.
*/
idx = rss_hash_val / RTE_RETA_GROUP_SIZE;
shift = rss_hash_val % RTE_RETA_GROUP_SIZE;
idx = rss_hash_val / RTE_ETH_RETA_GROUP_SIZE;
shift = rss_hash_val % RTE_ETH_RETA_GROUP_SIZE;
queue_id = gk_conf->rss_conf_front.reta_conf[idx].reta[shift];
block_idx = gk_conf->queue_id_to_instance[queue_id];

Expand Down
8 changes: 4 additions & 4 deletions gk/rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ gk_arp_and_nd_req_cb(const struct lls_map *map, void *arg,
* on the nexthop entry.
*/
write_seqlock(&eth_cache->lock);
rte_ether_addr_copy(&map->ha, &eth_cache->l2_hdr.eth_hdr.d_addr);
rte_ether_addr_copy(&map->ha, &eth_cache->l2_hdr.eth_hdr.dst_addr);
eth_cache->stale = map->stale;
write_sequnlock(&eth_cache->lock);

Expand Down Expand Up @@ -123,7 +123,7 @@ get_new_ether_cache_locked(struct neighbor_hash_table *neigh,
rte_cpu_to_be_16(addr->proto);
}
rte_ether_addr_copy(&iface->eth_addr,
&eth_cache->l2_hdr.eth_hdr.s_addr);
&eth_cache->l2_hdr.eth_hdr.src_addr);
rte_atomic32_set(&eth_cache->ref_cnt, 1);

return eth_cache;
Expand Down Expand Up @@ -2010,7 +2010,7 @@ fillup_gk_fib_dump_entry_ether(struct fib_dump_addr_set *addr_set,
{
addr_set->stale = eth_cache->stale;
addr_set->nexthop_ip = eth_cache->ip_addr;
rte_ether_addr_copy(&eth_cache->l2_hdr.eth_hdr.d_addr,
rte_ether_addr_copy(&eth_cache->l2_hdr.eth_hdr.dst_addr,
&addr_set->d_addr);
}

Expand Down Expand Up @@ -2278,7 +2278,7 @@ fillup_gk_neighbor_dump_entry(struct gk_neighbor_dump_entry *dentry,
dentry->stale = eth_cache->stale;
rte_memcpy(&dentry->neigh_ip, &eth_cache->ip_addr,
sizeof(dentry->neigh_ip));
rte_memcpy(&dentry->d_addr, &eth_cache->l2_hdr.eth_hdr.d_addr,
rte_memcpy(&dentry->d_addr, &eth_cache->l2_hdr.eth_hdr.dst_addr,
sizeof(dentry->d_addr));
}

Expand Down
24 changes: 12 additions & 12 deletions gt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ gt_arp_and_nd_req_cb(const struct lls_map *map, void *arg,
* on the nexthop entry.
*/
write_seqlock(&eth_cache->lock);
rte_ether_addr_copy(&map->ha, &eth_cache->l2_hdr.eth_hdr.d_addr);
rte_ether_addr_copy(&map->ha, &eth_cache->l2_hdr.eth_hdr.dst_addr);
eth_cache->stale = map->stale;
write_sequnlock(&eth_cache->lock);

Expand Down Expand Up @@ -516,7 +516,7 @@ gt_fill_up_ether_cache_locked(struct ether_cache *eth_cache,
}

rte_ether_addr_copy(&iface->eth_addr,
&eth_cache->l2_hdr.eth_hdr.s_addr);
&eth_cache->l2_hdr.eth_hdr.src_addr);
rte_atomic32_set(&eth_cache->ref_cnt, 1);

if (inner_ip_ver == RTE_ETHER_TYPE_IPV4) {
Expand Down Expand Up @@ -723,8 +723,8 @@ decap_and_fill_eth(struct rte_mbuf *m, struct gt_config *gt_conf,
rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
struct rte_ether_hdr *raw_eth = pkt_info->l2_hdr;

rte_ether_addr_copy(&raw_eth->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&raw_eth->d_addr, &eth_hdr->s_addr);
rte_ether_addr_copy(&raw_eth->src_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&raw_eth->dst_addr, &eth_hdr->src_addr);
m->l2_len = iface->l2_len_out;

if (iface->vlan_insert)
Expand Down Expand Up @@ -763,8 +763,8 @@ fill_eth_hdr_reverse(struct gatekeeper_if *iface, struct rte_ether_hdr *eth_hdr,
{
struct rte_ether_hdr *raw_eth =
(struct rte_ether_hdr *)pkt_info->l2_hdr;
rte_ether_addr_copy(&raw_eth->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&raw_eth->d_addr, &eth_hdr->s_addr);
rte_ether_addr_copy(&raw_eth->src_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&raw_eth->dst_addr, &eth_hdr->src_addr);
if (iface->vlan_insert) {
uint16_t vlan_tag_be =
pkt_info->outer_ethertype == RTE_ETHER_TYPE_IPV4 ?
Expand Down Expand Up @@ -843,7 +843,7 @@ fill_notify_pkt_hdr(struct rte_mbuf *notify_pkt,
notify_ipv4->dst_addr = ipv4_hdr->src_addr;

notify_pkt->l3_len = sizeof(struct rte_ipv4_hdr);
notify_pkt->ol_flags |= PKT_TX_IPV4;
notify_pkt->ol_flags |= RTE_MBUF_F_TX_IPV4;

/* IPv4 checksum set in prep_notify_pkt(). */
} else if (likely(ethertype == RTE_ETHER_TYPE_IPV6)) {
Expand All @@ -861,7 +861,7 @@ fill_notify_pkt_hdr(struct rte_mbuf *notify_pkt,
sizeof(notify_ipv6->dst_addr));

notify_pkt->l3_len = sizeof(struct rte_ipv6_hdr);
notify_pkt->ol_flags |= PKT_TX_IPV6;
notify_pkt->ol_flags |= RTE_MBUF_F_TX_IPV6;
}

/* Fill up the UDP header. */
Expand Down Expand Up @@ -1011,7 +1011,7 @@ prep_notify_pkt(struct ggu_notify_pkt *ggu_pkt, struct gatekeeper_if *iface)
notify_udp->dgram_len = dgram_len_be;
if (likely(iface->ipv4_hw_udp_cksum)) {
/* Offload the UDP checksum. */
ggu_pkt->buf->ol_flags |= PKT_TX_UDP_CKSUM;
ggu_pkt->buf->ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM;
notify_udp->dgram_cksum =
rte_ipv4_phdr_cksum(notify_ipv4,
ggu_pkt->buf->ol_flags);
Expand Down Expand Up @@ -1040,7 +1040,7 @@ prep_notify_pkt(struct ggu_notify_pkt *ggu_pkt, struct gatekeeper_if *iface)
notify_udp->dgram_len = dgram_len_be;
if (likely(iface->ipv6_hw_udp_cksum)) {
/* Offload the UDP checksum. */
ggu_pkt->buf->ol_flags |= PKT_TX_UDP_CKSUM;
ggu_pkt->buf->ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM;
notify_udp->dgram_cksum =
rte_ipv6_phdr_cksum(notify_ipv6,
ggu_pkt->buf->ol_flags);
Expand Down Expand Up @@ -1787,8 +1787,8 @@ gt_proc(void *arg)
if (reassembling_enabled && cur_tsc - last_tsc >=
frag_scan_timeout_cycles) {
RTE_VERIFY(death_row.cnt == 0);
rte_frag_table_del_expired_entries(instance->frag_tbl,
&death_row, cur_tsc);
rte_ip_frag_table_del_expired_entries(
instance->frag_tbl, &death_row, cur_tsc);

/* Process the death packets. */
process_death_row(true, &death_row,
Expand Down
7 changes: 4 additions & 3 deletions include/gatekeeper_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ struct ipaddr {
* of the table. To configure more than 64 entries supported by hardware,
* an array of this structure is needed.
*/
#define GATEKEEPER_RETA_MAX_SIZE (ETH_RSS_RETA_SIZE_512 / RTE_RETA_GROUP_SIZE)
#define GATEKEEPER_RETA_MAX_SIZE \
(RTE_ETH_RSS_RETA_SIZE_512 / RTE_ETH_RETA_GROUP_SIZE)

struct gatekeeper_rss_config {
uint16_t reta_size;
Expand Down Expand Up @@ -654,9 +655,9 @@ set_ipv4_checksum(struct gatekeeper_if *iface, struct rte_mbuf *pkt,
* computing the checksum (in hardware or software).
*/
ipv4->hdr_checksum = 0;
pkt->ol_flags |= PKT_TX_IPV4;
pkt->ol_flags |= RTE_MBUF_F_TX_IPV4;
if (likely(iface->ipv4_hw_cksum))
pkt->ol_flags |= PKT_TX_IP_CKSUM;
pkt->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM;
else
ipv4->hdr_checksum = rte_ipv4_cksum(ipv4);
}
Expand Down
Loading

0 comments on commit 9b648f7

Please sign in to comment.