xref: /f-stack/lib/ff_msg.h (revision 144c6bcd)
17abd0fb2Slogwang /*
27abd0fb2Slogwang  * Copyright (C) 2017 THL A29 Limited, a Tencent company.
37abd0fb2Slogwang  * All rights reserved.
47abd0fb2Slogwang  *
57abd0fb2Slogwang  * Redistribution and use in source and binary forms, with or without
67abd0fb2Slogwang  * modification, are permitted provided that the following conditions are met:
77abd0fb2Slogwang  *
87abd0fb2Slogwang  * 1. Redistributions of source code must retain the above copyright notice, this
97abd0fb2Slogwang  *   list of conditions and the following disclaimer.
107abd0fb2Slogwang  * 2. Redistributions in binary form must reproduce the above copyright notice,
117abd0fb2Slogwang  *   this list of conditions and the following disclaimer in the documentation
127abd0fb2Slogwang  *   and/or other materials provided with the distribution.
137abd0fb2Slogwang  *
147abd0fb2Slogwang  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
157abd0fb2Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
167abd0fb2Slogwang  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
177abd0fb2Slogwang  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
187abd0fb2Slogwang  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
197abd0fb2Slogwang  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
207abd0fb2Slogwang  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
217abd0fb2Slogwang  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
227abd0fb2Slogwang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
237abd0fb2Slogwang  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
247abd0fb2Slogwang  *
257abd0fb2Slogwang  */
267abd0fb2Slogwang 
277abd0fb2Slogwang #ifndef _FF_MSG_H_
287abd0fb2Slogwang #define _FF_MSG_H_
297abd0fb2Slogwang 
307abd0fb2Slogwang #include <rte_memory.h>
317abd0fb2Slogwang 
327abd0fb2Slogwang #define FF_MSG_RING_IN  "ff_msg_ring_in_"
337abd0fb2Slogwang #define FF_MSG_RING_OUT "ff_msg_ring_out_"
347abd0fb2Slogwang #define FF_MSG_POOL     "ff_msg_pool"
357abd0fb2Slogwang 
36df6ad731Slogwang /* MSG TYPE: sysctl, ioctl, etc.. */
377abd0fb2Slogwang enum FF_MSG_TYPE {
387abd0fb2Slogwang     FF_UNKNOWN = 0,
397abd0fb2Slogwang     FF_SYSCTL,
40df6ad731Slogwang     FF_IOCTL,
41*144c6bcdSlogwang     FF_ROUTE,
427abd0fb2Slogwang };
437abd0fb2Slogwang 
447abd0fb2Slogwang struct ff_sysctl_args {
457abd0fb2Slogwang     int *name;
467abd0fb2Slogwang     unsigned namelen;
477abd0fb2Slogwang     void *old;
487abd0fb2Slogwang     size_t *oldlenp;
497abd0fb2Slogwang     void *new;
507abd0fb2Slogwang     size_t newlen;
517abd0fb2Slogwang };
527abd0fb2Slogwang 
53df6ad731Slogwang struct ff_ioctl_args {
54df6ad731Slogwang     unsigned long cmd;
55df6ad731Slogwang     void *data;
56df6ad731Slogwang };
57df6ad731Slogwang 
58*144c6bcdSlogwang struct ff_route_args {
59*144c6bcdSlogwang     int fib;
60*144c6bcdSlogwang     unsigned len;
61*144c6bcdSlogwang     unsigned maxlen;
62*144c6bcdSlogwang     void *data;
63*144c6bcdSlogwang };
64*144c6bcdSlogwang 
657abd0fb2Slogwang #define MAX_MSG_BUF_SIZE 10240
667abd0fb2Slogwang 
677abd0fb2Slogwang /* structure of ipc msg */
687abd0fb2Slogwang struct ff_msg {
697abd0fb2Slogwang     enum FF_MSG_TYPE msg_type;
707abd0fb2Slogwang     /* Result of msg processing */
717abd0fb2Slogwang     int result;
727abd0fb2Slogwang     /* Length of segment buffer. */
737abd0fb2Slogwang     uint16_t buf_len;
747abd0fb2Slogwang     /* Address of segment buffer. */
757abd0fb2Slogwang     char *buf_addr;
767abd0fb2Slogwang 
777abd0fb2Slogwang     union {
787abd0fb2Slogwang         struct ff_sysctl_args sysctl;
79df6ad731Slogwang         struct ff_ioctl_args ioctl;
80*144c6bcdSlogwang         struct ff_route_args route;
817abd0fb2Slogwang     };
827abd0fb2Slogwang } __attribute__((packed)) __rte_cache_aligned;
837abd0fb2Slogwang 
847abd0fb2Slogwang #endif
85