-
Notifications
You must be signed in to change notification settings - Fork 1
/
rx_action.h
executable file
·106 lines (91 loc) · 3.16 KB
/
rx_action.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef __scable_rx_action__
#define __scable_rx_action__
#include "lcore_action.h"
#include "pkt_action.h"
#include "cipher_controller.h"
class Cipher2UncipherWorker;
class Uncipher2CipherWorker;
class RXAction {
private:
Port *port;
const LcoreActionDelegate<RXAction> lcoreActionDelegate;
RXAction()
: lcoreActionDelegate(this) {
}
public:
~RXAction() {
}
static RXAction *create() {
auto ret = new RXAction();
// ret->distributorRing = rte_ring_create(ret->distributorRingName("RXAction:"),
// CipherController::RTE_RING_SZ, rte_socket_id(), RING_F_SC_DEQ);
// if (ret->distributorRing == NULL) {
// LOG(ERROR) << "Cannot create output ring";
// delete ret;
// return 0;
// }
return ret;
}
void lcorePrepare(Lcore &lcore) {
LOG(INFO) << "Starting Lcore on:" << lcore.getId() << ":" << this
<< "=>" << name() << " for port " << port->getId();
}
void lcoreAction(Lcore &lcore) {
// const uint64_t drain_tsc =
// (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * port.BURST_TX_DRAIN_US;
// LOG(INFO) << "entering RxWorker::main_loop on lcore " << lcore_id;
// struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
// struct rte_mbuf *m;
// uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
// unsigned i, j, portid, nb_rx;
// for (unsigned i = 0; i < qconf.n_rx_port; i++) {
// portid = qconf.rx_port_list[i];
// LOG(INFO) << " -- lcoreid=" << lcore_id << " portid=" << portid;
// }
// uint64_t prev_tsc = 0;
// uint64_t timer_tsc = 0;
//const uint64_t cur_tsc = rte_rdtsc();
/*
* Read packet from RX queues
*/
struct rte_mbuf *pkts_burst[Port::MAX_PKT_BURST];
const uint16_t nb_rx = rte_eth_rx_burst(port->getId(), 0, pkts_burst, Port::MAX_PKT_BURST);
port->getPortStatistics().rx += nb_rx;
// if (nb_rx) {
// LOG(INFO) << "received:" << port->getId() << ":" << nb_rx;
// }
// unsigned ret = rte_ring_sp_enqueue_burst(distributorRing, (void **)pkts_burst, nb_rx);
// if (ret != nb_rx) {
// LOG(ERROR) << "lcoreAction:rte_ring_sp_enqueue_burst missed some packet " << nb_rx << ":" << ret;
// }
// if (nb_rx > 0) {
// unsigned rc = rte_ring_count(distributorRing);
// // LOG(INFO) << "cipherRXAction:" << distributorRing << ":" << port->getPortStatistics().rx << ":" << rc << ":" << nb_rx << ":" << ret;
// }
}
const LcoreAction& getAction() const {
return lcoreActionDelegate.get();
}
Port * getPort() const {
return port;
}
const char *name() const {
return "RXAction";
}
RXAction &bindPort(Port &p) {
port = &p;
return *this;
}
RXAction &bindWorker(Cipher2UncipherWorker &c) {
//cipher2UncipherWorker = &c;
return *this;
}
RXAction &bindWorker(Uncipher2CipherWorker &c) {
//uncipher2CipherWorker = &c;
return *this;
}
std::string toString() {
return port->toString();
}
};
#endif