Skip to content

Commit ee6c3aa

Browse files
committed
modify packet_dispatcher to support response package direct.
1 parent e10c878 commit ee6c3aa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/ff_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag,
144144

145145

146146
/* dispatch api begin */
147+
#define FF_DISPATCH_ERROR (-1)
148+
#define FF_DISPATCH_RESPONSE (-2)
147149

148150
/*
149151
* Packet dispatch callback function.
@@ -164,7 +166,7 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag,
164166
* Error occurs or packet is handled by user, packet will be freed.
165167
*
166168
*/
167-
typedef int (*dispatch_func_t)(void *data, uint16_t len,
169+
typedef int (*dispatch_func_t)(void *data, uint16_t *len,
168170
uint16_t queue_id, uint16_t nb_queues);
169171

170172
/* regist a packet dispath function */

lib/ff_dpdk_if.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ static dispatch_func_t packet_dispatcher;
172172

173173
static uint16_t rss_reta_size[RTE_MAX_ETHPORTS];
174174

175+
static inline int send_single_packet(struct rte_mbuf *m, uint8_t port);
176+
175177
struct ff_msg_ring {
176178
char ring_name[2][RTE_RING_NAMESIZE];
177179
/* ring[0] for lcore recv msg, other send */
@@ -1011,8 +1013,14 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
10111013
}
10121014

10131015
if (!pkts_from_ring && packet_dispatcher) {
1014-
int ret = (*packet_dispatcher)(data, len, queue_id, nb_queues);
1015-
if (ret < 0 || ret >= nb_queues) {
1016+
int ret = (*packet_dispatcher)(data, &len, queue_id, nb_queues);
1017+
if (ret == FF_DISPATCH_RESPONSE) {
1018+
rte_pktmbuf_pkt_len(rtem) = rte_pktmbuf_data_len(rtem) = len;
1019+
send_single_packet(rtem, port_id);
1020+
continue;
1021+
}
1022+
1023+
if (ret == FF_DISPATCH_ERROR || ret >= nb_queues) {
10161024
rte_pktmbuf_free(rtem);
10171025
continue;
10181026
}

0 commit comments

Comments
 (0)