17abd0fb2Slogwang /* 2*2317ada5Sfengbojiang * Copyright (C) 2017-2021 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, 41d7140ab7Sfengbojiang(姜凤波) FF_IOCTL6, 42144c6bcdSlogwang FF_ROUTE, 43e7741141SAndy FF_TOP, 443b2bd0f6Slogwang FF_NGCTL, 45127dd473Swhl739 FF_IPFW_CTL, 4603df98deSfengbojiang FF_TRAFFIC, 4747507c15Spengtian FF_KNICTL, 486194fcd2Sfengbojiang(姜凤波) 496194fcd2Sfengbojiang(姜凤波) /* 500f5432bbSfengbojiang * to add other msg type before FF_MSG_NUM 516194fcd2Sfengbojiang(姜凤波) */ 520f5432bbSfengbojiang FF_MSG_NUM, 537abd0fb2Slogwang }; 547abd0fb2Slogwang 557abd0fb2Slogwang struct ff_sysctl_args { 567abd0fb2Slogwang int *name; 577abd0fb2Slogwang unsigned namelen; 587abd0fb2Slogwang void *old; 597abd0fb2Slogwang size_t *oldlenp; 607abd0fb2Slogwang void *new; 617abd0fb2Slogwang size_t newlen; 627abd0fb2Slogwang }; 637abd0fb2Slogwang 64df6ad731Slogwang struct ff_ioctl_args { 65df6ad731Slogwang unsigned long cmd; 66df6ad731Slogwang void *data; 67df6ad731Slogwang }; 68df6ad731Slogwang 69144c6bcdSlogwang struct ff_route_args { 70144c6bcdSlogwang int fib; 71144c6bcdSlogwang unsigned len; 72144c6bcdSlogwang unsigned maxlen; 73144c6bcdSlogwang void *data; 74144c6bcdSlogwang }; 75144c6bcdSlogwang 76e7741141SAndy struct ff_top_args { 77e7741141SAndy unsigned long loops; 78e7741141SAndy unsigned long idle_tsc; 79e7741141SAndy unsigned long work_tsc; 80e7741141SAndy unsigned long sys_tsc; 81e7741141SAndy unsigned long usr_tsc; 82e7741141SAndy }; 83e7741141SAndy 843b2bd0f6Slogwang struct ff_ngctl_args { 853b2bd0f6Slogwang int cmd; 863b2bd0f6Slogwang int ret; 873b2bd0f6Slogwang void *data; 883b2bd0f6Slogwang }; 893b2bd0f6Slogwang 90127dd473Swhl739 enum FF_IPFW_CMD { 91127dd473Swhl739 FF_IPFW_GET, 92127dd473Swhl739 FF_IPFW_SET, 93127dd473Swhl739 }; 94127dd473Swhl739 95127dd473Swhl739 struct ff_ipfw_args { 96127dd473Swhl739 int cmd; 97127dd473Swhl739 int level; 98127dd473Swhl739 int optname; 99127dd473Swhl739 void *optval; 100127dd473Swhl739 socklen_t *optlen; 101127dd473Swhl739 }; 102127dd473Swhl739 10303df98deSfengbojiang struct ff_traffic_args { 10403df98deSfengbojiang uint64_t rx_packets; 10503df98deSfengbojiang uint64_t rx_bytes; 10603df98deSfengbojiang uint64_t tx_packets; 10703df98deSfengbojiang uint64_t tx_bytes; 10803df98deSfengbojiang }; 10903df98deSfengbojiang 11047507c15Spengtian enum FF_KNICTL_CMD { 11147507c15Spengtian FF_KNICTL_CMD_GET, 11247507c15Spengtian FF_KNICTL_CMD_SET, 11347507c15Spengtian FF_KNICTL_CMD_UNKNOWN, 11447507c15Spengtian }; 11547507c15Spengtian 11647507c15Spengtian enum FF_KNICTL_ACTION { 11747507c15Spengtian FF_KNICTL_ACTION_DEFAULT, 11847507c15Spengtian FF_KNICTL_ACTION_ALL_TO_KNI, 11947507c15Spengtian FF_KNICTL_ACTION_ALL_TO_FF, 12047507c15Spengtian FF_KNICTL_ACTION_MAX 12147507c15Spengtian }; 12247507c15Spengtian 12347507c15Spengtian struct ff_knictl_args { 12447507c15Spengtian int kni_cmd; 12547507c15Spengtian int kni_action; 12647507c15Spengtian }; 12747507c15Spengtian 12847507c15Spengtian 1297abd0fb2Slogwang #define MAX_MSG_BUF_SIZE 10240 1307abd0fb2Slogwang 1317abd0fb2Slogwang /* structure of ipc msg */ 1327abd0fb2Slogwang struct ff_msg { 1337abd0fb2Slogwang enum FF_MSG_TYPE msg_type; 1347abd0fb2Slogwang /* Result of msg processing */ 1357abd0fb2Slogwang int result; 1367abd0fb2Slogwang /* Length of segment buffer. */ 1371eaf0ac3Slogwang size_t buf_len; 1387abd0fb2Slogwang /* Address of segment buffer. */ 1397abd0fb2Slogwang char *buf_addr; 14032ff8fdaSfengbojiang char *original_buf; 14132ff8fdaSfengbojiang size_t original_buf_len; 1427abd0fb2Slogwang 1437abd0fb2Slogwang union { 1447abd0fb2Slogwang struct ff_sysctl_args sysctl; 145df6ad731Slogwang struct ff_ioctl_args ioctl; 146144c6bcdSlogwang struct ff_route_args route; 147e7741141SAndy struct ff_top_args top; 1483b2bd0f6Slogwang struct ff_ngctl_args ngctl; 149127dd473Swhl739 struct ff_ipfw_args ipfw; 15003df98deSfengbojiang struct ff_traffic_args traffic; 15147507c15Spengtian struct ff_knictl_args knictl; 1527abd0fb2Slogwang }; 1537abd0fb2Slogwang } __attribute__((packed)) __rte_cache_aligned; 1547abd0fb2Slogwang 1557abd0fb2Slogwang #endif 156