mirror of https://github.com/F-Stack/f-stack.git
modify packet_dispatcher to support response package direct.
This commit is contained in:
parent
0cf7df3b34
commit
c606218393
|
@ -144,6 +144,8 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag,
|
||||||
|
|
||||||
|
|
||||||
/* dispatch api begin */
|
/* dispatch api begin */
|
||||||
|
#define FF_DISPATCH_ERROR (-1)
|
||||||
|
#define FF_DISPATCH_RESPONSE (-2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Packet dispatch callback function.
|
* 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.
|
* 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);
|
uint16_t queue_id, uint16_t nb_queues);
|
||||||
|
|
||||||
/* regist a packet dispath function */
|
/* regist a packet dispath function */
|
||||||
|
|
|
@ -172,6 +172,8 @@ static dispatch_func_t packet_dispatcher;
|
||||||
|
|
||||||
static uint16_t rss_reta_size[RTE_MAX_ETHPORTS];
|
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 {
|
struct ff_msg_ring {
|
||||||
char ring_name[2][RTE_RING_NAMESIZE];
|
char ring_name[2][RTE_RING_NAMESIZE];
|
||||||
/* ring[0] for lcore recv msg, other send */
|
/* 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) {
|
if (!pkts_from_ring && packet_dispatcher) {
|
||||||
int ret = (*packet_dispatcher)(data, len, queue_id, nb_queues);
|
int ret = (*packet_dispatcher)(data, &len, queue_id, nb_queues);
|
||||||
if (ret < 0 || ret >= 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);
|
rte_pktmbuf_free(rtem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue