1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2023 Corigine, Inc. 3 * All rights reserved. 4 */ 5 6 #ifndef __NFP_NET_CMSG_H__ 7 #define __NFP_NET_CMSG_H__ 8 9 #include "nfp_net_common.h" 10 11 /** 12 * Match EtherType data 13 * 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 14 * -----\ 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 15 * Word +-------------------------------+-------------------------------+ 16 * 0 | | Ethtype | 17 * +-----------------+-------------+-------------------------------+ 18 */ 19 struct nfp_net_cmsg_match_eth { 20 uint16_t ether_type; 21 uint16_t spare; 22 }; 23 24 /** 25 * Match IPv4 data 26 * 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 27 * -----\ 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 28 * Word +-----+-------------------------+---------------+---------------+ 29 * 0 | | Position | L4 Proto | L4 Proto Mask | 30 * +-----+-------------------------+---------------+---------------+ 31 * 1 | SIP4 | 32 * +---------------------------------------------------------------+ 33 * 2 | SIP4 Mask | 34 * +---------------------------------------------------------------+ 35 * 3 | DIP4 | 36 * +---------------------------------------------------------------+ 37 * 4 | DIP4 Mask | 38 * +-------------------------------+-------------------------------+ 39 * 5 | SPort | SPort Mask | 40 * +-------------------------------+-------------------------------+ 41 * 6 | DPort | DPort Mask | 42 * +-----------------+-------------+-------------------------------+ 43 * 44 * Position – Position index of the rule, 13bits. 45 * As priority, smaller value indicates higher priority. 46 */ 47 struct nfp_net_cmsg_match_v4 { 48 uint8_t l4_protocol_mask; 49 uint8_t l4_protocol; 50 uint16_t position; 51 uint32_t src_ipv4; 52 uint32_t src_ipv4_mask; 53 uint32_t dst_ipv4; 54 uint32_t dst_ipv4_mask; 55 uint16_t src_port_mask; 56 uint16_t src_port; 57 uint16_t dst_port_mask; 58 uint16_t dst_port; 59 }; 60 61 /** 62 * Match IPv6 data 63 * 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 64 * -----\ 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 65 * Word +-----+-------------------------+---------------+---------------+ 66 * 0 | | Position | L4 Proto | L4 Proto Mask | 67 * +-----+-------------------------+---------------+---------------+ 68 * 1 | SIP6 (0-3B) | 69 * +---------------------------------------------------------------+ 70 * 2 | SIP6 (4-7B) | 71 * +---------------------------------------------------------------+ 72 * 3 | SIP6 (8-11B) | 73 * +---------------------------------------------------------------+ 74 * 4 | SIP6 (12-15B) | 75 * +---------------------------------------------------------------+ 76 * 5 | SIP6 Mask (0-3B) | 77 * +---------------------------------------------------------------+ 78 * 6 | SIP6 Mask (4-7B) | 79 * +---------------------------------------------------------------+ 80 * 7 | SIP6 Mask (8-11B) | 81 * +---------------------------------------------------------------+ 82 * 8 | SIP6 Mask (12-15B) | 83 * +---------------------------------------------------------------+ 84 * 9 | DIP6 (0-3B) | 85 * +---------------------------------------------------------------+ 86 * 10 | DIP6 (4-7B) | 87 * +---------------------------------------------------------------+ 88 * 11 | DIP6 (8-11B) | 89 * +---------------------------------------------------------------+ 90 * 12 | DIP6 (12-15B) | 91 * +---------------------------------------------------------------+ 92 * 13 | DIP6 Mask (0-3B) | 93 * +---------------------------------------------------------------+ 94 * 14 | DIP6 Mask (4-7B) | 95 * +---------------------------------------------------------------+ 96 * 15 | DIP6 Mask (8-11B) | 97 * +---------------------------------------------------------------+ 98 * 16 | DIP6 Mask (12-15B) | 99 * +-------------------------------+-------------------------------+ 100 * 17 | SPort | SPort Mask | 101 * +-------------------------------+-------------------------------+ 102 * 18 | DPort | DPort Mask | 103 * +-----------------+-------------+-------------------------------+ 104 * 105 * Position – Position index of the rule, 13bits. 106 * As priority, smaller value indicates higher priority. 107 */ 108 struct nfp_net_cmsg_match_v6 { 109 uint8_t l4_protocol_mask; 110 uint8_t l4_protocol; 111 uint16_t position; 112 uint8_t src_ipv6[16]; 113 uint8_t src_ipv6_mask[16]; 114 uint8_t dst_ipv6[16]; 115 uint8_t dst_ipv6_mask[16]; 116 uint16_t src_port_mask; 117 uint16_t src_port; 118 uint16_t dst_port_mask; 119 uint16_t dst_port; 120 }; 121 122 #define NFP_NET_CMSG_ACTION_DROP (0x1 << 0) /* Drop action */ 123 #define NFP_NET_CMSG_ACTION_QUEUE (0x1 << 1) /* Queue action */ 124 #define NFP_NET_CMSG_ACTION_MARK (0x1 << 2) /* Mark action */ 125 126 /** 127 * Action data 128 * 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 129 * -----\ 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 130 * Word +-------------------------------+-------------------------------+ 131 * 0 | | Queue | Actions | 132 * +-----------------+-------------+-------------------------------+ 133 * 1 | Mark ID | 134 * +---------------------------------------------------------------+ 135 * 136 * Queue – Queue ID, 7 bits. 137 * Actions – An action bitmap, each bit represents an action type: 138 * - Bit 0: Drop action. Drop the packet. 139 * - Bit 1: Queue action. Use the queue specified by “Queue” field. 140 * If not set, the queue is usually specified by RSS. 141 * - Bit 2: Mark action. Mark packet with Mark ID. 142 */ 143 struct nfp_net_cmsg_action { 144 uint16_t action; 145 uint8_t queue; 146 uint8_t spare; 147 uint32_t mark_id; 148 }; 149 150 enum nfp_net_cfg_mbox_cmd { 151 NFP_NET_CFG_MBOX_CMD_FS_ADD_V4, /* Add Flow Steer rule for V4 table */ 152 NFP_NET_CFG_MBOX_CMD_FS_DEL_V4, /* Delete Flow Steer rule for V4 table */ 153 NFP_NET_CFG_MBOX_CMD_FS_ADD_V6, /* Add Flow Steer rule for V4 table */ 154 NFP_NET_CFG_MBOX_CMD_FS_DEL_V6, /* Delete Flow Steer rule for V4 table */ 155 NFP_NET_CFG_MBOX_CMD_FS_ADD_ETHTYPE, /* Add Flow Steer rule for Ethtype table */ 156 NFP_NET_CFG_MBOX_CMD_FS_DEL_ETHTYPE, /* Delete Flow Steer rule for Ethtype table */ 157 }; 158 159 enum nfp_net_cfg_mbox_ret { 160 NFP_NET_CFG_MBOX_RET_FS_OK, /* No error happen */ 161 NFP_NET_CFG_MBOX_RET_FS_ERR_NO_SPACE, /* Return error code no space */ 162 NFP_NET_CFG_MBOX_RET_FS_ERR_MASK_FULL, /* Return error code mask table full */ 163 NFP_NET_CFG_MBOX_RET_FS_ERR_CMD_INVALID, /* Return error code invalid cmd */ 164 }; 165 166 /* 4B cmd, and up to 500B data. */ 167 struct nfp_net_cmsg { 168 uint32_t cmd; /**< One of nfp_net_cfg_mbox_cmd */ 169 uint32_t data[]; 170 }; 171 172 struct nfp_net_cmsg *nfp_net_cmsg_alloc(uint32_t msg_size); 173 void nfp_net_cmsg_free(struct nfp_net_cmsg *cmsg); 174 int nfp_net_cmsg_xmit(struct nfp_net_hw *hw, struct nfp_net_cmsg *cmsg, uint32_t msg_size); 175 176 #endif /* __NFP_NET_CMSG_H__ */ 177