From d9e0c21a28012fc84e90964a572f9c2eed2cb4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Tue, 25 Jun 2019 12:38:19 +0800 Subject: [PATCH] Add dispatch API reference. --- doc/F-Stack_API_Reference.md | 30 ++++++++++++++++++++++++++++++ lib/ff_api.h | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/F-Stack_API_Reference.md b/doc/F-Stack_API_Reference.md index 8cce0cb28..0f426aa68 100644 --- a/doc/F-Stack_API_Reference.md +++ b/doc/F-Stack_API_Reference.md @@ -220,3 +220,33 @@ However, it is supported only before F-Stack is started. #### Socket API for micro threads see `micro_thread/mt_api.h`. + +### Dispatch API + + Packet dispatch callback function, implemented by user. + + typedef int (*dispatch_func_t)(void *data, uint16_t *len, uint16_t queue_id, uint16_t nb_queues); + + void ff_regist_packet_dispatcher(dispatch_func_t func); + + Regist a packet dispath function. + +#### param + + - data + The data pointer of this packet. + - len + The length of this packet. + - queue_id + Current queue of this packet. + - nb_queues + Number of queues to be dispatched. + +#### return + + - 0 to (nb_queues - 1) + The queue id that the packet will be dispatched to. + - FF_DISPATCH_ERROR (-1) + Error occurs or packet is handled by user, packet will be freed. + - FF_DISPATCH_RESPONSE (-2) + Packet is handled by user, packet will be responsed. \ No newline at end of file diff --git a/lib/ff_api.h b/lib/ff_api.h index be80b7627..39d096704 100644 --- a/lib/ff_api.h +++ b/lib/ff_api.h @@ -162,8 +162,10 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag, * * @return 0 to (nb_queues - 1) * The queue id that the packet will be dispatched to. - * @return -1 + * @return FF_DISPATCH_ERROR (-1) * Error occurs or packet is handled by user, packet will be freed. +* @return FF_DISPATCH_RESPONSE (-2) + * Packet is handled by user, packet will be responsed. * */ typedef int (*dispatch_func_t)(void *data, uint16_t *len,