1ca65f2eeSChaoyong He /* SPDX-License-Identifier: BSD-3-Clause 2ca65f2eeSChaoyong He * Copyright (c) 2023 Corigine, Inc. 3ca65f2eeSChaoyong He * All rights reserved. 4ca65f2eeSChaoyong He */ 5ca65f2eeSChaoyong He 6ca65f2eeSChaoyong He #ifndef __NFP_NET_CMSG_H__ 7ca65f2eeSChaoyong He #define __NFP_NET_CMSG_H__ 8ca65f2eeSChaoyong He 9ca65f2eeSChaoyong He #include "nfp_net_common.h" 10ca65f2eeSChaoyong He 11c91c6512SChaoyong He /** 12c91c6512SChaoyong He * Match EtherType data 13c91c6512SChaoyong He * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 14c91c6512SChaoyong He * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 15c91c6512SChaoyong He * Word +-------------------------------+-------------------------------+ 16c91c6512SChaoyong He * 0 | | Ethtype | 17c91c6512SChaoyong He * +-----------------+-------------+-------------------------------+ 18c91c6512SChaoyong He */ 19c91c6512SChaoyong He struct nfp_net_cmsg_match_eth { 20c91c6512SChaoyong He uint16_t ether_type; 21c91c6512SChaoyong He uint16_t spare; 22c91c6512SChaoyong He }; 23c91c6512SChaoyong He 2442eabda0SChaoyong He /** 2542eabda0SChaoyong He * Match IPv4 data 2642eabda0SChaoyong He * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 2742eabda0SChaoyong He * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 2842eabda0SChaoyong He * Word +-----+-------------------------+---------------+---------------+ 2942eabda0SChaoyong He * 0 | | Position | L4 Proto | L4 Proto Mask | 3042eabda0SChaoyong He * +-----+-------------------------+---------------+---------------+ 3142eabda0SChaoyong He * 1 | SIP4 | 3242eabda0SChaoyong He * +---------------------------------------------------------------+ 3342eabda0SChaoyong He * 2 | SIP4 Mask | 3442eabda0SChaoyong He * +---------------------------------------------------------------+ 3542eabda0SChaoyong He * 3 | DIP4 | 3642eabda0SChaoyong He * +---------------------------------------------------------------+ 3742eabda0SChaoyong He * 4 | DIP4 Mask | 3842eabda0SChaoyong He * +-------------------------------+-------------------------------+ 3942eabda0SChaoyong He * 5 | SPort | SPort Mask | 4042eabda0SChaoyong He * +-------------------------------+-------------------------------+ 4142eabda0SChaoyong He * 6 | DPort | DPort Mask | 4242eabda0SChaoyong He * +-----------------+-------------+-------------------------------+ 4342eabda0SChaoyong He * 4442eabda0SChaoyong He * Position – Position index of the rule, 13bits. 4542eabda0SChaoyong He * As priority, smaller value indicates higher priority. 4642eabda0SChaoyong He */ 4742eabda0SChaoyong He struct nfp_net_cmsg_match_v4 { 4842eabda0SChaoyong He uint8_t l4_protocol_mask; 4942eabda0SChaoyong He uint8_t l4_protocol; 5042eabda0SChaoyong He uint16_t position; 5142eabda0SChaoyong He uint32_t src_ipv4; 5242eabda0SChaoyong He uint32_t src_ipv4_mask; 5342eabda0SChaoyong He uint32_t dst_ipv4; 5442eabda0SChaoyong He uint32_t dst_ipv4_mask; 5542eabda0SChaoyong He uint16_t src_port_mask; 567fc094a0SLong Wu uint16_t src_port; 5742eabda0SChaoyong He uint16_t dst_port_mask; 587fc094a0SLong Wu uint16_t dst_port; 5942eabda0SChaoyong He }; 6042eabda0SChaoyong He 619f27cb88SChaoyong He /** 629f27cb88SChaoyong He * Match IPv6 data 639f27cb88SChaoyong He * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 649f27cb88SChaoyong He * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 659f27cb88SChaoyong He * Word +-----+-------------------------+---------------+---------------+ 669f27cb88SChaoyong He * 0 | | Position | L4 Proto | L4 Proto Mask | 679f27cb88SChaoyong He * +-----+-------------------------+---------------+---------------+ 689f27cb88SChaoyong He * 1 | SIP6 (0-3B) | 699f27cb88SChaoyong He * +---------------------------------------------------------------+ 709f27cb88SChaoyong He * 2 | SIP6 (4-7B) | 719f27cb88SChaoyong He * +---------------------------------------------------------------+ 729f27cb88SChaoyong He * 3 | SIP6 (8-11B) | 739f27cb88SChaoyong He * +---------------------------------------------------------------+ 749f27cb88SChaoyong He * 4 | SIP6 (12-15B) | 759f27cb88SChaoyong He * +---------------------------------------------------------------+ 769f27cb88SChaoyong He * 5 | SIP6 Mask (0-3B) | 779f27cb88SChaoyong He * +---------------------------------------------------------------+ 789f27cb88SChaoyong He * 6 | SIP6 Mask (4-7B) | 799f27cb88SChaoyong He * +---------------------------------------------------------------+ 809f27cb88SChaoyong He * 7 | SIP6 Mask (8-11B) | 819f27cb88SChaoyong He * +---------------------------------------------------------------+ 829f27cb88SChaoyong He * 8 | SIP6 Mask (12-15B) | 839f27cb88SChaoyong He * +---------------------------------------------------------------+ 849f27cb88SChaoyong He * 9 | DIP6 (0-3B) | 859f27cb88SChaoyong He * +---------------------------------------------------------------+ 869f27cb88SChaoyong He * 10 | DIP6 (4-7B) | 879f27cb88SChaoyong He * +---------------------------------------------------------------+ 889f27cb88SChaoyong He * 11 | DIP6 (8-11B) | 899f27cb88SChaoyong He * +---------------------------------------------------------------+ 909f27cb88SChaoyong He * 12 | DIP6 (12-15B) | 919f27cb88SChaoyong He * +---------------------------------------------------------------+ 929f27cb88SChaoyong He * 13 | DIP6 Mask (0-3B) | 939f27cb88SChaoyong He * +---------------------------------------------------------------+ 949f27cb88SChaoyong He * 14 | DIP6 Mask (4-7B) | 959f27cb88SChaoyong He * +---------------------------------------------------------------+ 969f27cb88SChaoyong He * 15 | DIP6 Mask (8-11B) | 979f27cb88SChaoyong He * +---------------------------------------------------------------+ 989f27cb88SChaoyong He * 16 | DIP6 Mask (12-15B) | 999f27cb88SChaoyong He * +-------------------------------+-------------------------------+ 1009f27cb88SChaoyong He * 17 | SPort | SPort Mask | 1019f27cb88SChaoyong He * +-------------------------------+-------------------------------+ 1029f27cb88SChaoyong He * 18 | DPort | DPort Mask | 1039f27cb88SChaoyong He * +-----------------+-------------+-------------------------------+ 1049f27cb88SChaoyong He * 1059f27cb88SChaoyong He * Position – Position index of the rule, 13bits. 1069f27cb88SChaoyong He * As priority, smaller value indicates higher priority. 1079f27cb88SChaoyong He */ 1089f27cb88SChaoyong He struct nfp_net_cmsg_match_v6 { 1099f27cb88SChaoyong He uint8_t l4_protocol_mask; 1109f27cb88SChaoyong He uint8_t l4_protocol; 1119f27cb88SChaoyong He uint16_t position; 1129f27cb88SChaoyong He uint8_t src_ipv6[16]; 1139f27cb88SChaoyong He uint8_t src_ipv6_mask[16]; 1149f27cb88SChaoyong He uint8_t dst_ipv6[16]; 1159f27cb88SChaoyong He uint8_t dst_ipv6_mask[16]; 1169f27cb88SChaoyong He uint16_t src_port_mask; 1179f27cb88SChaoyong He uint16_t src_port; 1189f27cb88SChaoyong He uint16_t dst_port_mask; 1199f27cb88SChaoyong He uint16_t dst_port; 1209f27cb88SChaoyong He }; 1219f27cb88SChaoyong He 1220b9079d2SChaoyong He #define NFP_NET_CMSG_ACTION_DROP (0x1 << 0) /* Drop action */ 1230b9079d2SChaoyong He #define NFP_NET_CMSG_ACTION_QUEUE (0x1 << 1) /* Queue action */ 1240b9079d2SChaoyong He #define NFP_NET_CMSG_ACTION_MARK (0x1 << 2) /* Mark action */ 1250b9079d2SChaoyong He 1260b9079d2SChaoyong He /** 1270b9079d2SChaoyong He * Action data 1280b9079d2SChaoyong He * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1290b9079d2SChaoyong He * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1300b9079d2SChaoyong He * Word +-------------------------------+-------------------------------+ 1310b9079d2SChaoyong He * 0 | | Queue | Actions | 1320b9079d2SChaoyong He * +-----------------+-------------+-------------------------------+ 1330b9079d2SChaoyong He * 1 | Mark ID | 1340b9079d2SChaoyong He * +---------------------------------------------------------------+ 1350b9079d2SChaoyong He * 1360b9079d2SChaoyong He * Queue – Queue ID, 7 bits. 1370b9079d2SChaoyong He * Actions – An action bitmap, each bit represents an action type: 1380b9079d2SChaoyong He * - Bit 0: Drop action. Drop the packet. 1390b9079d2SChaoyong He * - Bit 1: Queue action. Use the queue specified by “Queue” field. 1400b9079d2SChaoyong He * If not set, the queue is usually specified by RSS. 1410b9079d2SChaoyong He * - Bit 2: Mark action. Mark packet with Mark ID. 1420b9079d2SChaoyong He */ 1430b9079d2SChaoyong He struct nfp_net_cmsg_action { 1440b9079d2SChaoyong He uint16_t action; 1450b9079d2SChaoyong He uint8_t queue; 1460b9079d2SChaoyong He uint8_t spare; 147*70258d8fSLong Wu uint32_t mark_id; 1480b9079d2SChaoyong He }; 1490b9079d2SChaoyong He 150ca65f2eeSChaoyong He enum nfp_net_cfg_mbox_cmd { 151ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_ADD_V4, /* Add Flow Steer rule for V4 table */ 152ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_DEL_V4, /* Delete Flow Steer rule for V4 table */ 153ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_ADD_V6, /* Add Flow Steer rule for V4 table */ 154ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_DEL_V6, /* Delete Flow Steer rule for V4 table */ 155ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_ADD_ETHTYPE, /* Add Flow Steer rule for Ethtype table */ 156ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_CMD_FS_DEL_ETHTYPE, /* Delete Flow Steer rule for Ethtype table */ 157ca65f2eeSChaoyong He }; 158ca65f2eeSChaoyong He 159ca65f2eeSChaoyong He enum nfp_net_cfg_mbox_ret { 160ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_RET_FS_OK, /* No error happen */ 161ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_RET_FS_ERR_NO_SPACE, /* Return error code no space */ 162ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_RET_FS_ERR_MASK_FULL, /* Return error code mask table full */ 163ca65f2eeSChaoyong He NFP_NET_CFG_MBOX_RET_FS_ERR_CMD_INVALID, /* Return error code invalid cmd */ 164ca65f2eeSChaoyong He }; 165ca65f2eeSChaoyong He 166ca65f2eeSChaoyong He /* 4B cmd, and up to 500B data. */ 167ca65f2eeSChaoyong He struct nfp_net_cmsg { 168ca65f2eeSChaoyong He uint32_t cmd; /**< One of nfp_net_cfg_mbox_cmd */ 169ca65f2eeSChaoyong He uint32_t data[]; 170ca65f2eeSChaoyong He }; 171ca65f2eeSChaoyong He 172ca65f2eeSChaoyong He struct nfp_net_cmsg *nfp_net_cmsg_alloc(uint32_t msg_size); 173ca65f2eeSChaoyong He void nfp_net_cmsg_free(struct nfp_net_cmsg *cmsg); 174ca65f2eeSChaoyong He int nfp_net_cmsg_xmit(struct nfp_net_hw *hw, struct nfp_net_cmsg *cmsg, uint32_t msg_size); 175ca65f2eeSChaoyong He 176ca65f2eeSChaoyong He #endif /* __NFP_NET_CMSG_H__ */ 177