modify packet_dispatcher to support response package direct.

dev
fengbojiang(姜凤波) 2019-03-08 15:12:57 +08:00
parent e10c878da7
commit ee6c3aa356
2 changed files with 13 additions and 3 deletions

View File

@ -144,6 +144,8 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag,
/* dispatch api begin */
#define FF_DISPATCH_ERROR (-1)
#define FF_DISPATCH_RESPONSE (-2)
/*
* Packet dispatch callback function.
@ -164,7 +166,7 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag,
* Error occurs or packet is handled by user, packet will be freed.
*
*/
typedef int (*dispatch_func_t)(void *data, uint16_t len,
typedef int (*dispatch_func_t)(void *data, uint16_t *len,
uint16_t queue_id, uint16_t nb_queues);
/* regist a packet dispath function */

View File

@ -172,6 +172,8 @@ static dispatch_func_t packet_dispatcher;
static uint16_t rss_reta_size[RTE_MAX_ETHPORTS];
static inline int send_single_packet(struct rte_mbuf *m, uint8_t port);
struct ff_msg_ring {
char ring_name[2][RTE_RING_NAMESIZE];
/* 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,
}
if (!pkts_from_ring && packet_dispatcher) {
int ret = (*packet_dispatcher)(data, len, queue_id, nb_queues);
if (ret < 0 || ret >= nb_queues) {
int ret = (*packet_dispatcher)(data, &len, queue_id, nb_queues);
if (ret == FF_DISPATCH_RESPONSE) {
rte_pktmbuf_pkt_len(rtem) = rte_pktmbuf_data_len(rtem) = len;
send_single_packet(rtem, port_id);
continue;
}
if (ret == FF_DISPATCH_ERROR || ret >= nb_queues) {
rte_pktmbuf_free(rtem);
continue;
}