Skip to content

Commit 890bb18

Browse files
committed
ethface: GTP-IP N6 on EthDev
1 parent 090517d commit 890bb18

File tree

9 files changed

+362
-191
lines changed

9 files changed

+362
-191
lines changed

csrc/ethface/gtpip.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
55

66
#include "../dpdk/hashtable.h"
77
#include "../dpdk/mbuf.h"
8+
#include "../iface/faceid.h"
9+
#include <rte_ether.h>
810

911
/** @brief GTP-IP handler. */
1012
typedef struct EthGtpip {
13+
/**
14+
* @brief N6 face.
15+
*
16+
* When set, N6 traffic is sent/received on this port instead of @c EthPassthru.tapPort .
17+
*/
18+
FaceID n6Face;
19+
uint8_t n6Mac[2 * RTE_ETHER_ADDR_LEN];
20+
1121
/**
1222
* @brief Mapping from UE IPv4 address to FaceID.
1323
*

csrc/ethface/passthru.c

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,37 @@
33
#include "face.h"
44
#include "gtpip.h"
55

6+
__attribute__((nonnull)) static inline void
7+
EthPassthru_FaceRxInput_Gtpip(FaceRxThread* rxt, EthGtpip* g, FaceRxInputCtx* ctx, uint16_t* nPkts,
8+
uint16_t* nTx) {
9+
uint64_t gtpipMask = EthGtpip_ProcessUplinkBulk(g, ctx->pkts, ctx->count);
10+
if (gtpipMask == 0) {
11+
// no GTP-IP packets
12+
return;
13+
}
14+
15+
uint16_t nGtpip = rte_popcount64(gtpipMask);
16+
rxt->nFrames[EthPassthru_cntNGtpip] += nGtpip;
17+
*nPkts -= nGtpip;
18+
if (g->n6Face == 0) {
19+
// GTP-IP packets are interleaved with other packets and will be sent via TAP netif
20+
return;
21+
}
22+
23+
// GTP-IP packets must be separated from other packets and will be sent via N6 face
24+
for (uint16_t i = 0, jPkt = 0, jGtpip = 0; i < ctx->count; ++i) {
25+
struct rte_mbuf* pkt = ctx->pkts[i];
26+
if (rte_bit_test(&gtpipMask, i)) {
27+
rte_memcpy(rte_pktmbuf_mtod(pkt, uint8_t*), g->n6Mac, sizeof(g->n6Mac));
28+
ctx->npkts[jGtpip++] = (Packet*)pkt;
29+
} else {
30+
ctx->pkts[jPkt++] = pkt;
31+
}
32+
}
33+
Face_TxBurst(g->n6Face, ctx->npkts, nGtpip);
34+
*nTx = *nPkts;
35+
}
36+
637
void
738
EthPassthru_FaceRxInput(Face* face, int rxThread, FaceRxInputCtx* ctx) {
839
FaceRxThread* rxt = &face->impl->rx[rxThread];
@@ -13,18 +44,23 @@ EthPassthru_FaceRxInput(Face* face, int rxThread, FaceRxInputCtx* ctx) {
1344
struct rte_mbuf* pkt = ctx->pkts[i];
1445
rxt->nFrames[FaceRxThread_cntNOctets] += pkt->pkt_len;
1546
}
16-
if (pt->gtpip == NULL) {
17-
rxt->nFrames[EthPassthru_cntNPkts] += ctx->count;
18-
} else {
19-
uint64_t nGtpip = rte_popcount64(EthGtpip_ProcessUplinkBulk(pt->gtpip, ctx->pkts, ctx->count));
20-
rxt->nFrames[EthPassthru_cntNGtpip] += nGtpip;
21-
rxt->nFrames[EthPassthru_cntNPkts] += ctx->count - nGtpip;
47+
48+
uint16_t nPkts = ctx->count; // how many packets to be counted in the nPkts counter
49+
uint16_t nTx = ctx->count; // how many packets to be transmitted via TAP netif
50+
if (pt->gtpip != NULL) {
51+
EthPassthru_FaceRxInput_Gtpip(rxt, pt->gtpip, ctx, &nPkts, &nTx);
52+
}
53+
rxt->nFrames[EthPassthru_cntNPkts] += nPkts;
54+
55+
if (pt->n3Face != 0) {
56+
Face_TxBurst(pt->n3Face, (Packet**)ctx->pkts, nTx);
57+
return;
2258
}
2359

2460
uint16_t nSent = 0;
2561
uint16_t tapPort = pt->tapPort;
26-
if (likely(tapPort != UINT16_MAX)) {
27-
nSent = rte_eth_tx_burst(pt->tapPort, 0, ctx->pkts, ctx->count);
62+
if (likely(tapPort != UINT16_MAX) && nTx > 0) {
63+
nSent = rte_eth_tx_burst(pt->tapPort, 0, ctx->pkts, nTx);
2864
}
2965
ctx->nFree = ctx->count - nSent;
3066
if (unlikely(ctx->nFree > 0)) {

csrc/ethface/passthru.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum {
2222
typedef struct EthPassthru {
2323
RxGroup base;
2424
uint16_t tapPort;
25+
FaceID n3Face;
2526
EthGtpip* gtpip;
2627
} EthPassthru;
2728

@@ -33,7 +34,6 @@ typedef struct EthPassthru {
3334
*/
3435
__attribute__((nonnull)) void
3536
EthPassthru_FaceRxInput(Face* face, int rxThread, FaceRxInputCtx* ctx);
36-
;
3737

3838
/**
3939
* @brief Receive Ethernet frames on a TAP ethdev associated with a pass-through face.

0 commit comments

Comments
 (0)