Skip to content

Commit

Permalink
patch: lldp bonding xmit patch for dpdk
Browse files Browse the repository at this point in the history
Signed-off-by: ywc689 <[email protected]>
  • Loading branch information
ywc689 committed Jul 30, 2024
1 parent 3a941f3 commit 8808be5
Showing 1 changed file with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
From 7024d80414e914a54c301dbcc9bb4cf6fb5f927b Mon Sep 17 00:00:00 2001
From: yuwenchao <[email protected]>
Date: Tue, 30 Jul 2024 15:39:28 +0800
Subject: [PATCH] bonding device sends packets with user specified salve port

The outgoing slave port is specified in mbuf field "hash.txadapter.reserved2".
Support the following 3 bonding mode:
- mode 0: round robin
- mode 2: balance
- mode 4: 8023ad

Signed-off-by: yuwenchao <[email protected]>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 26 ++++++++++++++++++++++++--
lib/librte_mbuf/rte_mbuf.h | 2 ++
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 42e436c..a35422c 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -573,6 +573,22 @@ struct client_stats_t {
return nb_recv_pkts;
}

+static inline int
+bond_ethdev_populate_slave_by_user(const struct rte_mbuf *mbuf, const uint16_t *slaves,
+ int num_slave)
+{
+ uint16_t i, pid = mbuf->hash.txadapter.reserved2;
+
+ if (likely(pid == RTE_MBUF_PORT_INVALID))
+ return -1;
+
+ for (i = 0; i < num_slave; i++) {
+ if (slaves[i] == pid)
+ return i;
+ }
+ return -1;
+}
+
static uint16_t
bond_ethdev_tx_burst_round_robin(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts)
@@ -605,7 +621,9 @@ struct client_stats_t {

/* Populate slaves mbuf with which packets are to be sent on it */
for (i = 0; i < nb_pkts; i++) {
- cslave_idx = (slave_idx + i) % num_of_slaves;
+ cslave_idx = bond_ethdev_populate_slave_by_user(bufs[i], slaves, num_of_slaves);
+ if (likely(cslave_idx < 0))
+ cslave_idx = (slave_idx + i) % num_of_slaves;
slave_bufs[cslave_idx][(slave_nb_pkts[cslave_idx])++] = bufs[i];
}

@@ -1162,7 +1180,11 @@ struct bwg_slave {

for (i = 0; i < nb_bufs; i++) {
/* Populate slave mbuf arrays with mbufs for that slave. */
- uint16_t slave_idx = bufs_slave_port_idxs[i];
+ int slave_idx;
+
+ slave_idx = bond_ethdev_populate_slave_by_user(bufs[i], slave_port_ids, slave_count);
+ if (likely(slave_idx < 0))
+ slave_idx = bufs_slave_port_idxs[i];

slave_bufs[slave_idx][slave_nb_bufs[slave_idx]++] = bufs[i];
}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index c4c9ebf..130b99d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -589,6 +589,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)

if (rte_mempool_get(mp, (void **)&m) < 0)
return NULL;
+ m->hash.txadapter.reserved2 = RTE_MBUF_PORT_INVALID;
__rte_mbuf_raw_sanity_check(m);
return m;
}
@@ -867,6 +868,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->vlan_tci_outer = 0;
m->nb_segs = 1;
m->port = RTE_MBUF_PORT_INVALID;
+ m->hash.txadapter.reserved2 = RTE_MBUF_PORT_INVALID;

m->ol_flags &= EXT_ATTACHED_MBUF;
m->packet_type = 0;
--
1.8.3.1

0 comments on commit 8808be5

Please sign in to comment.