3
3
#include "face.h"
4
4
#include "gtpip.h"
5
5
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
+
6
37
void
7
38
EthPassthru_FaceRxInput (Face * face , int rxThread , FaceRxInputCtx * ctx ) {
8
39
FaceRxThread * rxt = & face -> impl -> rx [rxThread ];
@@ -13,18 +44,23 @@ EthPassthru_FaceRxInput(Face* face, int rxThread, FaceRxInputCtx* ctx) {
13
44
struct rte_mbuf * pkt = ctx -> pkts [i ];
14
45
rxt -> nFrames [FaceRxThread_cntNOctets ] += pkt -> pkt_len ;
15
46
}
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 ;
22
58
}
23
59
24
60
uint16_t nSent = 0 ;
25
61
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 );
28
64
}
29
65
ctx -> nFree = ctx -> count - nSent ;
30
66
if (unlikely (ctx -> nFree > 0 )) {
0 commit comments