Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2015 Freescale Semiconductor |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | #ifndef _FSL_DPNI_H |
| 7 | #define _FSL_DPNI_H |
| 8 | |
| 9 | /* DPNI Version */ |
| 10 | #define DPNI_VER_MAJOR 4 |
| 11 | #define DPNI_VER_MINOR 0 |
| 12 | |
| 13 | /* Command IDs */ |
| 14 | #define DPNI_CMDID_OPEN 0x801 |
| 15 | #define DPNI_CMDID_CLOSE 0x800 |
| 16 | |
| 17 | #define DPNI_CMDID_ENABLE 0x002 |
| 18 | #define DPNI_CMDID_DISABLE 0x003 |
| 19 | #define DPNI_CMDID_GET_ATTR 0x004 |
| 20 | #define DPNI_CMDID_RESET 0x005 |
| 21 | |
| 22 | #define DPNI_CMDID_SET_POOLS 0x200 |
| 23 | #define DPNI_CMDID_GET_RX_BUFFER_LAYOUT 0x201 |
| 24 | #define DPNI_CMDID_SET_RX_BUFFER_LAYOUT 0x202 |
| 25 | #define DPNI_CMDID_GET_TX_BUFFER_LAYOUT 0x203 |
| 26 | #define DPNI_CMDID_SET_TX_BUFFER_LAYOUT 0x204 |
| 27 | #define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT 0x205 |
| 28 | #define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT 0x206 |
| 29 | |
| 30 | #define DPNI_CMDID_GET_QDID 0x210 |
| 31 | #define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212 |
| 32 | #define DPNI_CMDID_GET_COUNTER 0x213 |
| 33 | #define DPNI_CMDID_SET_COUNTER 0x214 |
| 34 | #define DPNI_CMDID_GET_LINK_STATE 0x215 |
| 35 | #define DPNI_CMDID_SET_LINK_CFG 0x21A |
| 36 | |
| 37 | #define DPNI_CMDID_SET_PRIM_MAC 0x224 |
| 38 | #define DPNI_CMDID_GET_PRIM_MAC 0x225 |
| 39 | #define DPNI_CMDID_ADD_MAC_ADDR 0x226 |
| 40 | #define DPNI_CMDID_REMOVE_MAC_ADDR 0x227 |
| 41 | |
| 42 | #define DPNI_CMDID_SET_TX_FLOW 0x236 |
| 43 | #define DPNI_CMDID_GET_TX_FLOW 0x237 |
| 44 | #define DPNI_CMDID_SET_RX_FLOW 0x238 |
| 45 | #define DPNI_CMDID_GET_RX_FLOW 0x239 |
| 46 | |
| 47 | /* cmd, param, offset, width, type, arg_name */ |
| 48 | #define DPNI_CMD_OPEN(cmd, dpni_id) \ |
| 49 | MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id) |
| 50 | |
| 51 | |
| 52 | /* cmd, param, offset, width, type, arg_name */ |
| 53 | #define DPNI_CMD_SET_POOLS(cmd, cfg) \ |
| 54 | do { \ |
| 55 | MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \ |
| 56 | MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \ |
| 57 | MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\ |
| 58 | MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \ |
| 59 | MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\ |
| 60 | MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \ |
| 61 | MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\ |
| 62 | MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \ |
| 63 | MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\ |
| 64 | MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \ |
| 65 | MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\ |
| 66 | MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \ |
| 67 | MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\ |
| 68 | MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \ |
| 69 | MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\ |
| 70 | MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \ |
| 71 | MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\ |
| 72 | } while (0) |
| 73 | |
| 74 | /* cmd, param, offset, width, type, arg_name */ |
| 75 | #define DPNI_RSP_GET_ATTR(cmd, attr) \ |
| 76 | do { \ |
| 77 | MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\ |
| 78 | MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \ |
| 79 | MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \ |
| 80 | MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \ |
| 81 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->options); \ |
| 82 | MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \ |
| 83 | MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\ |
| 84 | MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \ |
| 85 | MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \ |
| 86 | MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \ |
| 87 | MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \ |
| 88 | MC_RSP_OP(cmd, 3, 0, 8, uint8_t, attr->max_dist_per_tc[0]); \ |
| 89 | MC_RSP_OP(cmd, 3, 8, 8, uint8_t, attr->max_dist_per_tc[1]); \ |
| 90 | MC_RSP_OP(cmd, 3, 16, 8, uint8_t, attr->max_dist_per_tc[2]); \ |
| 91 | MC_RSP_OP(cmd, 3, 24, 8, uint8_t, attr->max_dist_per_tc[3]); \ |
| 92 | MC_RSP_OP(cmd, 3, 32, 8, uint8_t, attr->max_dist_per_tc[4]); \ |
| 93 | MC_RSP_OP(cmd, 3, 40, 8, uint8_t, attr->max_dist_per_tc[5]); \ |
| 94 | MC_RSP_OP(cmd, 3, 48, 8, uint8_t, attr->max_dist_per_tc[6]); \ |
| 95 | MC_RSP_OP(cmd, 3, 56, 8, uint8_t, attr->max_dist_per_tc[7]); \ |
| 96 | MC_RSP_OP(cmd, 4, 0, 16, uint16_t, \ |
| 97 | attr->ipr_cfg.max_reass_frm_size); \ |
| 98 | MC_RSP_OP(cmd, 4, 16, 16, uint16_t, \ |
| 99 | attr->ipr_cfg.min_frag_size_ipv4); \ |
| 100 | MC_RSP_OP(cmd, 4, 32, 16, uint16_t, \ |
| 101 | attr->ipr_cfg.min_frag_size_ipv6); \ |
| 102 | MC_RSP_OP(cmd, 5, 0, 16, uint16_t, \ |
| 103 | attr->ipr_cfg.max_open_frames_ipv4); \ |
| 104 | MC_RSP_OP(cmd, 5, 16, 16, uint16_t, \ |
| 105 | attr->ipr_cfg.max_open_frames_ipv6); \ |
| 106 | MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\ |
| 107 | MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\ |
| 108 | } while (0) |
| 109 | |
| 110 | /* cmd, param, offset, width, type, arg_name */ |
| 111 | #define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \ |
| 112 | do { \ |
| 113 | MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 114 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 115 | MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 116 | MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 117 | MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 118 | MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 119 | MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 120 | } while (0) |
| 121 | |
| 122 | /* cmd, param, offset, width, type, arg_name */ |
| 123 | #define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \ |
| 124 | do { \ |
| 125 | MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 126 | MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 127 | MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \ |
| 128 | MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 129 | MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 130 | MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 131 | MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 132 | MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 133 | } while (0) |
| 134 | |
| 135 | /* cmd, param, offset, width, type, arg_name */ |
| 136 | #define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \ |
| 137 | do { \ |
| 138 | MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 139 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 140 | MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 141 | MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 142 | MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 143 | MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 144 | MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 145 | } while (0) |
| 146 | |
| 147 | /* cmd, param, offset, width, type, arg_name */ |
| 148 | #define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \ |
| 149 | do { \ |
| 150 | MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 151 | MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 152 | MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \ |
| 153 | MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 154 | MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 155 | MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 156 | MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 157 | MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 158 | } while (0) |
| 159 | |
| 160 | /* cmd, param, offset, width, type, arg_name */ |
| 161 | #define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \ |
| 162 | do { \ |
| 163 | MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 164 | MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 165 | MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 166 | MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 167 | MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 168 | MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 169 | MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 170 | } while (0) |
| 171 | |
| 172 | /* cmd, param, offset, width, type, arg_name */ |
| 173 | #define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \ |
| 174 | do { \ |
| 175 | MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \ |
| 176 | MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \ |
| 177 | MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \ |
| 178 | MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \ |
| 179 | MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \ |
| 180 | MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \ |
| 181 | MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \ |
| 182 | MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \ |
| 183 | } while (0) |
| 184 | |
| 185 | /* cmd, param, offset, width, type, arg_name */ |
| 186 | #define DPNI_RSP_GET_QDID(cmd, qdid) \ |
| 187 | MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid) |
| 188 | |
| 189 | /* cmd, param, offset, width, type, arg_name */ |
| 190 | #define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \ |
| 191 | MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset) |
| 192 | |
| 193 | /* cmd, param, offset, width, type, arg_name */ |
| 194 | #define DPNI_CMD_GET_COUNTER(cmd, counter) \ |
| 195 | MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter) |
| 196 | |
| 197 | /* cmd, param, offset, width, type, arg_name */ |
| 198 | #define DPNI_RSP_GET_COUNTER(cmd, value) \ |
| 199 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value) |
| 200 | |
| 201 | /* cmd, param, offset, width, type, arg_name */ |
| 202 | #define DPNI_CMD_SET_COUNTER(cmd, counter, value) \ |
| 203 | do { \ |
| 204 | MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \ |
| 205 | MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \ |
| 206 | } while (0) |
| 207 | |
| 208 | /* cmd, param, offset, width, type, arg_name */ |
| 209 | #define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \ |
| 210 | do { \ |
| 211 | MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->rate);\ |
| 212 | MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\ |
| 213 | } while (0) |
| 214 | |
| 215 | /* cmd, param, offset, width, type, arg_name */ |
| 216 | #define DPNI_RSP_GET_LINK_STATE(cmd, state) \ |
| 217 | do { \ |
| 218 | MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\ |
| 219 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, state->rate);\ |
| 220 | MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\ |
| 221 | } while (0) |
| 222 | |
| 223 | |
| 224 | |
| 225 | /* cmd, param, offset, width, type, arg_name */ |
| 226 | #define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ |
| 227 | do { \ |
| 228 | MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ |
| 229 | MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ |
| 230 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ |
| 231 | MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ |
| 232 | MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ |
| 233 | MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ |
| 234 | } while (0) |
| 235 | |
| 236 | /* cmd, param, offset, width, type, arg_name */ |
| 237 | #define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \ |
| 238 | do { \ |
| 239 | MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ |
| 240 | MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ |
| 241 | MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ |
| 242 | MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ |
| 243 | MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ |
| 244 | MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ |
| 245 | } while (0) |
| 246 | |
| 247 | /* cmd, param, offset, width, type, arg_name */ |
| 248 | #define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \ |
| 249 | do { \ |
| 250 | MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ |
| 251 | MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ |
| 252 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ |
| 253 | MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ |
| 254 | MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ |
| 255 | MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ |
| 256 | } while (0) |
| 257 | |
| 258 | /* cmd, param, offset, width, type, arg_name */ |
| 259 | #define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \ |
| 260 | do { \ |
| 261 | MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \ |
| 262 | MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \ |
| 263 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \ |
| 264 | MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \ |
| 265 | MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \ |
| 266 | MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \ |
| 267 | } while (0) |
| 268 | |
| 269 | /* cmd, param, offset, width, type, arg_name */ |
| 270 | #define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \ |
| 271 | do { \ |
| 272 | MC_CMD_OP(cmd, 0, 0, 32, int, \ |
| 273 | cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_id);\ |
| 274 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, \ |
| 275 | cfg->conf_err_cfg.queue_cfg.dest_cfg.priority);\ |
| 276 | MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \ |
| 277 | cfg->conf_err_cfg.queue_cfg.dest_cfg.dest_type);\ |
| 278 | MC_CMD_OP(cmd, 0, 42, 1, int, cfg->conf_err_cfg.errors_only);\ |
| 279 | MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\ |
| 280 | MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\ |
| 281 | MC_CMD_OP(cmd, 0, 45, 1, int, \ |
| 282 | cfg->conf_err_cfg.use_default_queue);\ |
| 283 | MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\ |
| 284 | MC_CMD_OP(cmd, 1, 0, 64, uint64_t, \ |
| 285 | cfg->conf_err_cfg.queue_cfg.user_ctx);\ |
| 286 | MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\ |
| 287 | MC_CMD_OP(cmd, 2, 32, 32, uint32_t, \ |
| 288 | cfg->conf_err_cfg.queue_cfg.options);\ |
| 289 | } while (0) |
| 290 | |
| 291 | /* cmd, param, offset, width, type, arg_name */ |
| 292 | #define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \ |
| 293 | MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id) |
| 294 | |
| 295 | /* cmd, param, offset, width, type, arg_name */ |
| 296 | #define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \ |
| 297 | MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id) |
| 298 | |
| 299 | /* cmd, param, offset, width, type, arg_name */ |
| 300 | #define DPNI_RSP_GET_TX_FLOW(cmd, attr) \ |
| 301 | do { \ |
| 302 | MC_RSP_OP(cmd, 0, 0, 32, int, \ |
| 303 | attr->conf_err_attr.queue_attr.dest_cfg.dest_id);\ |
| 304 | MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \ |
| 305 | attr->conf_err_attr.queue_attr.dest_cfg.priority);\ |
| 306 | MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \ |
| 307 | attr->conf_err_attr.queue_attr.dest_cfg.dest_type);\ |
| 308 | MC_RSP_OP(cmd, 0, 42, 1, int, attr->conf_err_attr.errors_only);\ |
| 309 | MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\ |
| 310 | MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\ |
| 311 | MC_RSP_OP(cmd, 0, 45, 1, int, \ |
| 312 | attr->conf_err_attr.use_default_queue);\ |
| 313 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, \ |
| 314 | attr->conf_err_attr.queue_attr.user_ctx);\ |
| 315 | MC_RSP_OP(cmd, 2, 32, 32, uint32_t, \ |
| 316 | attr->conf_err_attr.queue_attr.fqid);\ |
| 317 | } while (0) |
| 318 | |
| 319 | /* cmd, param, offset, width, type, arg_name */ |
| 320 | #define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \ |
| 321 | do { \ |
| 322 | MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \ |
| 323 | MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\ |
| 324 | MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\ |
| 325 | MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \ |
| 326 | MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \ |
| 327 | MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \ |
| 328 | MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \ |
| 329 | } while (0) |
| 330 | |
| 331 | /* cmd, param, offset, width, type, arg_name */ |
| 332 | #define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \ |
| 333 | do { \ |
| 334 | MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \ |
| 335 | MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \ |
| 336 | } while (0) |
| 337 | |
| 338 | /* cmd, param, offset, width, type, arg_name */ |
| 339 | #define DPNI_RSP_GET_RX_FLOW(cmd, attr) \ |
| 340 | do { \ |
| 341 | MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \ |
| 342 | MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\ |
| 343 | MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \ |
| 344 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \ |
| 345 | MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \ |
| 346 | } while (0) |
| 347 | |
| 348 | enum net_prot { |
| 349 | NET_PROT_NONE = 0, |
| 350 | NET_PROT_PAYLOAD, |
| 351 | NET_PROT_ETH, |
| 352 | NET_PROT_VLAN, |
| 353 | NET_PROT_IPV4, |
| 354 | NET_PROT_IPV6, |
| 355 | NET_PROT_IP, |
| 356 | NET_PROT_TCP, |
| 357 | NET_PROT_UDP, |
| 358 | NET_PROT_UDP_LITE, |
| 359 | NET_PROT_IPHC, |
| 360 | NET_PROT_SCTP, |
| 361 | NET_PROT_SCTP_CHUNK_DATA, |
| 362 | NET_PROT_PPPOE, |
| 363 | NET_PROT_PPP, |
| 364 | NET_PROT_PPPMUX, |
| 365 | NET_PROT_PPPMUX_SUBFRM, |
| 366 | NET_PROT_L2TPV2, |
| 367 | NET_PROT_L2TPV3_CTRL, |
| 368 | NET_PROT_L2TPV3_SESS, |
| 369 | NET_PROT_LLC, |
| 370 | NET_PROT_LLC_SNAP, |
| 371 | NET_PROT_NLPID, |
| 372 | NET_PROT_SNAP, |
| 373 | NET_PROT_MPLS, |
| 374 | NET_PROT_IPSEC_AH, |
| 375 | NET_PROT_IPSEC_ESP, |
| 376 | NET_PROT_UDP_ENC_ESP, /* RFC 3948 */ |
| 377 | NET_PROT_MACSEC, |
| 378 | NET_PROT_GRE, |
| 379 | NET_PROT_MINENCAP, |
| 380 | NET_PROT_DCCP, |
| 381 | NET_PROT_ICMP, |
| 382 | NET_PROT_IGMP, |
| 383 | NET_PROT_ARP, |
| 384 | NET_PROT_CAPWAP_DATA, |
| 385 | NET_PROT_CAPWAP_CTRL, |
| 386 | NET_PROT_RFC2684, |
| 387 | NET_PROT_ICMPV6, |
| 388 | NET_PROT_FCOE, |
| 389 | NET_PROT_FIP, |
| 390 | NET_PROT_ISCSI, |
| 391 | NET_PROT_GTP, |
| 392 | NET_PROT_USER_DEFINED_L2, |
| 393 | NET_PROT_USER_DEFINED_L3, |
| 394 | NET_PROT_USER_DEFINED_L4, |
| 395 | NET_PROT_USER_DEFINED_L5, |
| 396 | NET_PROT_USER_DEFINED_SHIM1, |
| 397 | NET_PROT_USER_DEFINED_SHIM2, |
| 398 | |
| 399 | NET_PROT_DUMMY_LAST |
| 400 | }; |
| 401 | |
| 402 | /* Data Path Network Interface API |
| 403 | * Contains initialization APIs and runtime control APIs for DPNI |
| 404 | */ |
| 405 | |
| 406 | struct fsl_mc_io; |
| 407 | |
| 408 | /* General DPNI macros */ |
| 409 | |
| 410 | /* Maximum number of traffic classes */ |
| 411 | #define DPNI_MAX_TC 8 |
| 412 | /* Maximum number of buffer pools per DPNI */ |
| 413 | #define DPNI_MAX_DPBP 8 |
| 414 | |
| 415 | /* All traffic classes considered; see dpni_set_rx_flow() */ |
| 416 | #define DPNI_ALL_TCS (uint8_t)(-1) |
| 417 | /* All flows within traffic class considered; see dpni_set_rx_flow() */ |
| 418 | #define DPNI_ALL_TC_FLOWS (uint16_t)(-1) |
| 419 | /* Generate new flow ID; see dpni_set_tx_flow() */ |
| 420 | #define DPNI_NEW_FLOW_ID (uint16_t)(-1) |
| 421 | |
| 422 | /** |
| 423 | * dpni_open() - Open a control session for the specified object |
| 424 | * @mc_io: Pointer to MC portal's I/O object |
| 425 | * @dpni_id: DPNI unique ID |
| 426 | * @token: Returned token; use in subsequent API calls |
| 427 | * |
| 428 | * This function can be used to open a control session for an |
| 429 | * already created object; an object may have been declared in |
| 430 | * the DPL or by calling the dpni_create() function. |
| 431 | * This function returns a unique authentication token, |
| 432 | * associated with the specific object ID and the specific MC |
| 433 | * portal; this token must be used in all subsequent commands for |
| 434 | * this specific object. |
| 435 | * |
| 436 | * Return: '0' on Success; Error code otherwise. |
| 437 | */ |
| 438 | int dpni_open(struct fsl_mc_io *mc_io, int dpni_id, uint16_t *token); |
| 439 | |
| 440 | /** |
| 441 | * dpni_close() - Close the control session of the object |
| 442 | * @mc_io: Pointer to MC portal's I/O object |
| 443 | * @token: Token of DPNI object |
| 444 | * |
| 445 | * After this function is called, no further operations are |
| 446 | * allowed on the object without opening a new control session. |
| 447 | * |
| 448 | * Return: '0' on Success; Error code otherwise. |
| 449 | */ |
| 450 | int dpni_close(struct fsl_mc_io *mc_io, uint16_t token); |
| 451 | |
| 452 | /** |
| 453 | * struct dpni_ipr_cfg - Structure representing IP reassembly configuration |
| 454 | * @max_reass_frm_size: Maximum size of the reassembled frame |
| 455 | * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments |
| 456 | * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments |
| 457 | * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly process |
| 458 | * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly process |
| 459 | */ |
| 460 | struct dpni_ipr_cfg { |
| 461 | uint16_t max_reass_frm_size; |
| 462 | uint16_t min_frag_size_ipv4; |
| 463 | uint16_t min_frag_size_ipv6; |
| 464 | uint16_t max_open_frames_ipv4; |
| 465 | uint16_t max_open_frames_ipv6; |
| 466 | }; |
| 467 | |
| 468 | /** |
| 469 | * struct dpni_pools_cfg - Structure representing buffer pools configuration |
| 470 | * @num_dpbp: Number of DPBPs |
| 471 | * @pools: Array of buffer pools parameters; The number of valid entries |
| 472 | * must match 'num_dpbp' value |
| 473 | */ |
| 474 | struct dpni_pools_cfg { |
| 475 | uint8_t num_dpbp; |
| 476 | /** |
| 477 | * struct pools - Buffer pools parameters |
| 478 | * @dpbp_id: DPBP object ID |
| 479 | * @buffer_size: Buffer size |
| 480 | */ |
| 481 | struct { |
| 482 | int dpbp_id; |
| 483 | uint16_t buffer_size; |
| 484 | } pools[DPNI_MAX_DPBP]; |
| 485 | }; |
| 486 | |
| 487 | /** |
| 488 | * dpni_set_pools() - Set buffer pools configuration |
| 489 | * @mc_io: Pointer to MC portal's I/O object |
| 490 | * @token: Token of DPNI object |
| 491 | * @cfg: Buffer pools configuration |
| 492 | * |
| 493 | * mandatory for DPNI operation |
| 494 | * warning:Allowed only when DPNI is disabled |
| 495 | * |
| 496 | * Return: '0' on Success; Error code otherwise. |
| 497 | */ |
| 498 | int dpni_set_pools(struct fsl_mc_io *mc_io, |
| 499 | uint16_t token, |
| 500 | const struct dpni_pools_cfg *cfg); |
| 501 | |
| 502 | /** |
| 503 | * dpni_enable() - Enable the DPNI, allow sending and receiving frames. |
| 504 | * @mc_io: Pointer to MC portal's I/O object |
| 505 | * @token: Token of DPNI object |
| 506 | * |
| 507 | * Return: '0' on Success; Error code otherwise. |
| 508 | */ |
| 509 | int dpni_enable(struct fsl_mc_io *mc_io, uint16_t token); |
| 510 | |
| 511 | /** |
| 512 | * dpni_disable() - Disable the DPNI, stop sending and receiving frames. |
| 513 | * @mc_io: Pointer to MC portal's I/O object |
| 514 | * @token: Token of DPNI object |
| 515 | * |
| 516 | * Return: '0' on Success; Error code otherwise. |
| 517 | */ |
| 518 | int dpni_disable(struct fsl_mc_io *mc_io, uint16_t token); |
| 519 | |
| 520 | |
| 521 | /** |
| 522 | * @dpni_reset() - Reset the DPNI, returns the object to initial state. |
| 523 | * @mc_io: Pointer to MC portal's I/O object |
| 524 | * @token: Token of DPNI object |
| 525 | * |
| 526 | * Return: '0' on Success; Error code otherwise. |
| 527 | */ |
| 528 | int dpni_reset(struct fsl_mc_io *mc_io, uint16_t token); |
| 529 | |
| 530 | /** |
| 531 | * struct dpni_attr - Structure representing DPNI attributes |
| 532 | * @id: DPNI object ID |
| 533 | * @version: DPNI version |
| 534 | * @start_hdr: Indicates the packet starting header for parsing |
| 535 | * @options: Mask of available options; reflects the value as was given in |
| 536 | * object's creation |
| 537 | * @max_senders: Maximum number of different senders; used as the number |
| 538 | * of dedicated Tx flows; |
| 539 | * @max_tcs: Maximum number of traffic classes (for both Tx and Rx) |
| 540 | * @max_dist_per_tc: Maximum distribution size per Rx traffic class; |
| 541 | * Set to the required value minus 1 |
| 542 | * @max_unicast_filters: Maximum number of unicast filters |
| 543 | * @max_multicast_filters: Maximum number of multicast filters |
| 544 | * @max_vlan_filters: Maximum number of VLAN filters |
| 545 | * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table |
| 546 | * @max_qos_key_size: Maximum key size for the QoS look-up |
| 547 | * @max_dist_key_size: Maximum key size for the distribution look-up |
| 548 | * @ipr_cfg: IP reassembly configuration |
| 549 | */ |
| 550 | struct dpni_attr { |
| 551 | int id; |
| 552 | /** |
| 553 | * struct version - DPNI version |
| 554 | * @major: DPNI major version |
| 555 | * @minor: DPNI minor version |
| 556 | */ |
| 557 | struct { |
| 558 | uint16_t major; |
| 559 | uint16_t minor; |
| 560 | } version; |
| 561 | enum net_prot start_hdr; |
| 562 | uint64_t options; |
| 563 | uint8_t max_senders; |
| 564 | uint8_t max_tcs; |
| 565 | uint8_t max_dist_per_tc[DPNI_MAX_TC]; |
| 566 | uint8_t max_unicast_filters; |
| 567 | uint8_t max_multicast_filters; |
| 568 | uint8_t max_vlan_filters; |
| 569 | uint8_t max_qos_entries; |
| 570 | uint8_t max_qos_key_size; |
| 571 | uint8_t max_dist_key_size; |
| 572 | struct dpni_ipr_cfg ipr_cfg; |
| 573 | }; |
| 574 | /** |
| 575 | * dpni_get_attributes() - Retrieve DPNI attributes. |
| 576 | * @mc_io: Pointer to MC portal's I/O objec |
| 577 | * @token: Token of DPNI object |
| 578 | * @attr: Returned object's attributes |
| 579 | * |
| 580 | * Return: '0' on Success; Error code otherwise. |
| 581 | */ |
| 582 | int dpni_get_attributes(struct fsl_mc_io *mc_io, |
| 583 | uint16_t token, |
| 584 | struct dpni_attr *attr); |
| 585 | |
| 586 | /* DPNI buffer layout modification options */ |
| 587 | |
| 588 | /* Select to modify the time-stamp setting */ |
| 589 | #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001 |
| 590 | /* Select to modify the parser-result setting; not applicable for Tx */ |
| 591 | #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002 |
| 592 | /* Select to modify the frame-status setting */ |
| 593 | #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004 |
| 594 | /* Select to modify the private-data-size setting */ |
| 595 | #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008 |
| 596 | /* Select to modify the data-alignment setting */ |
| 597 | #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010 |
| 598 | /* Select to modify the data-head-room setting */ |
| 599 | #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020 |
| 600 | /*!< Select to modify the data-tail-room setting */ |
| 601 | #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040 |
| 602 | |
| 603 | /** |
| 604 | * struct dpni_buffer_layout - Structure representing DPNI buffer layout |
| 605 | * @options: Flags representing the suggested modifications to the buffer |
| 606 | * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags |
| 607 | * @pass_timestamp: Pass timestamp value |
| 608 | * @pass_parser_result: Pass parser results |
| 609 | * @pass_frame_status: Pass frame status |
| 610 | * @private_data_size: Size kept for private data (in bytes) |
| 611 | * @data_align: Data alignment |
| 612 | * @data_head_room: Data head room |
| 613 | * @data_tail_room: Data tail room |
| 614 | */ |
| 615 | struct dpni_buffer_layout { |
| 616 | uint32_t options; |
| 617 | int pass_timestamp; |
| 618 | int pass_parser_result; |
| 619 | int pass_frame_status; |
| 620 | uint16_t private_data_size; |
| 621 | uint16_t data_align; |
| 622 | uint16_t data_head_room; |
| 623 | uint16_t data_tail_room; |
| 624 | }; |
| 625 | |
| 626 | /** |
| 627 | * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes. |
| 628 | * @mc_io: Pointer to MC portal's I/O object |
| 629 | * @token: Token of DPNI object |
| 630 | * @layout: Returns buffer layout attributes |
| 631 | * |
| 632 | * Return: '0' on Success; Error code otherwise. |
| 633 | */ |
| 634 | int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io, |
| 635 | uint16_t token, |
| 636 | struct dpni_buffer_layout *layout); |
| 637 | /** |
| 638 | * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration. |
| 639 | * @mc_io: Pointer to MC portal's I/O object |
| 640 | * @token: Token of DPNI object |
| 641 | * @layout: Buffer layout configuration |
| 642 | * |
| 643 | * Return: '0' on Success; Error code otherwise. |
| 644 | * |
| 645 | * @warning Allowed only when DPNI is disabled |
| 646 | */ |
| 647 | int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io, |
| 648 | uint16_t token, |
| 649 | const struct dpni_buffer_layout *layout); |
| 650 | |
| 651 | /** |
| 652 | * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes. |
| 653 | * @mc_io: Pointer to MC portal's I/O object |
| 654 | * @token: Token of DPNI object |
| 655 | * @layout: Returns buffer layout attributes |
| 656 | * |
| 657 | * Return: '0' on Success; Error code otherwise. |
| 658 | */ |
| 659 | int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io, |
| 660 | uint16_t token, |
| 661 | struct dpni_buffer_layout *layout); |
| 662 | |
| 663 | /** |
| 664 | * @brief Set Tx buffer layout configuration. |
| 665 | * |
| 666 | * @param[in] mc_io Pointer to MC portal's I/O object |
| 667 | * @param[in] token Token of DPNI object |
| 668 | * @param[in] layout Buffer layout configuration |
| 669 | * |
| 670 | * @returns '0' on Success; Error code otherwise. |
| 671 | * |
| 672 | * @warning Allowed only when DPNI is disabled |
| 673 | */ |
| 674 | int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io, |
| 675 | uint16_t token, |
| 676 | const struct dpni_buffer_layout *layout); |
| 677 | /** |
| 678 | * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout |
| 679 | * attributes. |
| 680 | * @mc_io: Pointer to MC portal's I/O object |
| 681 | * @token: Token of DPNI object |
| 682 | * @layout: Returns buffer layout attributes |
| 683 | * |
| 684 | * Return: '0' on Success; Error code otherwise. |
| 685 | */ |
| 686 | int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io, |
| 687 | uint16_t token, |
| 688 | struct dpni_buffer_layout *layout); |
| 689 | /** |
| 690 | * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout |
| 691 | * configuration. |
| 692 | * @mc_io: Pointer to MC portal's I/O object |
| 693 | * @token: Token of DPNI object |
| 694 | * @layout: Buffer layout configuration |
| 695 | * |
| 696 | * Return: '0' on Success; Error code otherwise. |
| 697 | * |
| 698 | * @warning Allowed only when DPNI is disabled |
| 699 | */ |
| 700 | int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io, |
| 701 | uint16_t token, |
| 702 | const struct dpni_buffer_layout *layout); |
| 703 | /** |
| 704 | * dpni_get_spid() - Get the AIOP storage profile ID associated with the DPNI |
| 705 | * @mc_io: Pointer to MC portal's I/O object |
| 706 | * @token: Token of DPNI object |
| 707 | * @spid: Returned aiop storage-profile ID |
| 708 | * |
| 709 | * Return: '0' on Success; Error code otherwise. |
| 710 | * |
| 711 | * @warning Only relevant for DPNI that belongs to AIOP container. |
| 712 | */ |
| 713 | int dpni_get_qdid(struct fsl_mc_io *mc_io, uint16_t token, uint16_t *qdid); |
| 714 | |
| 715 | /** |
| 716 | * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer) |
| 717 | * @mc_io: Pointer to MC portal's I/O object |
| 718 | * @token: Token of DPNI object |
| 719 | * @data_offset: Tx data offset (from start of buffer) |
| 720 | * |
| 721 | * Return: '0' on Success; Error code otherwise. |
| 722 | */ |
| 723 | int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, |
| 724 | uint16_t token, |
| 725 | uint16_t *data_offset); |
| 726 | |
| 727 | /** |
| 728 | * enum dpni_counter - DPNI counter types |
| 729 | * @DPNI_CNT_ING_FRAME: Counts ingress frames |
| 730 | * @DPNI_CNT_ING_BYTE: Counts ingress bytes |
| 731 | * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit |
| 732 | * 'drop' setting |
| 733 | * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors |
| 734 | * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames |
| 735 | * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes |
| 736 | * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames |
| 737 | * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes |
| 738 | * @DPNI_CNT_EGR_FRAME: Counts egress frames |
| 739 | * @DPNI_CNT_EGR_BYTE: Counts egress bytes |
| 740 | * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors |
| 741 | */ |
| 742 | enum dpni_counter { |
| 743 | DPNI_CNT_ING_FRAME = 0x0, |
| 744 | DPNI_CNT_ING_BYTE = 0x1, |
| 745 | DPNI_CNT_ING_FRAME_DROP = 0x2, |
| 746 | DPNI_CNT_ING_FRAME_DISCARD = 0x3, |
| 747 | DPNI_CNT_ING_MCAST_FRAME = 0x4, |
| 748 | DPNI_CNT_ING_MCAST_BYTE = 0x5, |
| 749 | DPNI_CNT_ING_BCAST_FRAME = 0x6, |
| 750 | DPNI_CNT_ING_BCAST_BYTES = 0x7, |
| 751 | DPNI_CNT_EGR_FRAME = 0x8, |
| 752 | DPNI_CNT_EGR_BYTE = 0x9, |
| 753 | DPNI_CNT_EGR_FRAME_DISCARD = 0xa |
| 754 | }; |
| 755 | |
| 756 | /** |
| 757 | * dpni_get_counter() - Read a specific DPNI counter |
| 758 | * @mc_io: Pointer to MC portal's I/O object |
| 759 | * @token: Token of DPNI object |
| 760 | * @counter: The requested counter |
| 761 | * @value: Returned counter's current value |
| 762 | * |
| 763 | * Return: '0' on Success; Error code otherwise. |
| 764 | */ |
| 765 | int dpni_get_counter(struct fsl_mc_io *mc_io, |
| 766 | uint16_t token, |
| 767 | enum dpni_counter counter, |
| 768 | uint64_t *value); |
| 769 | |
| 770 | /** |
| 771 | * dpni_set_counter() - Set (or clear) a specific DPNI counter |
| 772 | * @mc_io: Pointer to MC portal's I/O object |
| 773 | * @token: Token of DPNI object |
| 774 | * @counter: The requested counter |
| 775 | * @value: New counter value; typically pass '0' for resetting |
| 776 | * the counter. |
| 777 | * |
| 778 | * Return: '0' on Success; Error code otherwise. |
| 779 | */ |
| 780 | int dpni_set_counter(struct fsl_mc_io *mc_io, |
| 781 | uint16_t token, |
| 782 | enum dpni_counter counter, |
| 783 | uint64_t value); |
| 784 | /** |
| 785 | * struct - Structure representing DPNI link configuration |
| 786 | * @rate: Rate |
| 787 | * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values |
| 788 | */ |
| 789 | struct dpni_link_cfg { |
| 790 | uint64_t rate; |
| 791 | uint64_t options; |
| 792 | }; |
| 793 | |
| 794 | /** |
| 795 | * dpni_set_link_cfg() - set the link configuration. |
| 796 | * @mc_io: Pointer to MC portal's I/O object |
| 797 | * @token: Token of DPNI object |
| 798 | * @cfg: Link configuration |
| 799 | * |
| 800 | * Return: '0' on Success; Error code otherwise. |
| 801 | */ |
| 802 | int dpni_set_link_cfg(struct fsl_mc_io *mc_io, |
| 803 | uint16_t token, |
| 804 | struct dpni_link_cfg *cfg); |
| 805 | |
| 806 | /** |
| 807 | * struct dpni_link_state - Structure representing DPNI link state |
| 808 | * @rate: Rate |
| 809 | * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values |
| 810 | * @up: Link state; '0' for down, '1' for up |
| 811 | */ |
| 812 | struct dpni_link_state { |
| 813 | uint64_t rate; |
| 814 | uint64_t options; |
| 815 | int up; |
| 816 | }; |
| 817 | |
| 818 | /** |
| 819 | * dpni_get_link_state() - Return the link state (either up or down) |
| 820 | * @mc_io: Pointer to MC portal's I/O object |
| 821 | * @token: Token of DPNI object |
| 822 | * @state: Returned link state; |
| 823 | * |
| 824 | * Return: '0' on Success; Error code otherwise. |
| 825 | */ |
| 826 | int dpni_get_link_state(struct fsl_mc_io *mc_io, |
| 827 | uint16_t token, |
| 828 | struct dpni_link_state *state); |
| 829 | |
| 830 | /** |
| 831 | * dpni_set_primary_mac_addr() - Set the primary MAC address |
| 832 | * @mc_io: Pointer to MC portal's I/O object |
| 833 | * @token: Token of DPNI object |
| 834 | * @mac_addr: MAC address to set as primary address |
| 835 | * |
| 836 | * Return: '0' on Success; Error code otherwise. |
| 837 | */ |
| 838 | int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, |
| 839 | uint16_t token, |
| 840 | const uint8_t mac_addr[6]); |
| 841 | /** |
| 842 | * dpni_get_primary_mac_addr() - Get the primary MAC address |
| 843 | * @mc_io: Pointer to MC portal's I/O object |
| 844 | * @token: Token of DPNI object |
| 845 | * @mac_addr: Returned MAC address |
| 846 | * |
| 847 | * Return: '0' on Success; Error code otherwise. |
| 848 | */ |
| 849 | int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, |
| 850 | uint16_t token, |
| 851 | uint8_t mac_addr[6]); |
| 852 | /** |
| 853 | * dpni_add_mac_addr() - Add MAC address filter |
| 854 | * @mc_io: Pointer to MC portal's I/O object |
| 855 | * @token: Token of DPNI object |
| 856 | * @mac_addr: MAC address to add |
| 857 | * |
| 858 | * Return: '0' on Success; Error code otherwise. |
| 859 | */ |
| 860 | int dpni_add_mac_addr(struct fsl_mc_io *mc_io, |
| 861 | uint16_t token, |
| 862 | const uint8_t mac_addr[6]); |
| 863 | |
| 864 | /** |
| 865 | * dpni_remove_mac_addr() - Remove MAC address filter |
| 866 | * @mc_io: Pointer to MC portal's I/O object |
| 867 | * @token: Token of DPNI object |
| 868 | * @mac_addr: MAC address to remove |
| 869 | * |
| 870 | * Return: '0' on Success; Error code otherwise. |
| 871 | */ |
| 872 | int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, |
| 873 | uint16_t token, |
| 874 | const uint8_t mac_addr[6]); |
| 875 | |
| 876 | /** |
| 877 | * enum dpni_dest - DPNI destination types |
| 878 | * DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and |
| 879 | * does not generate FQDAN notifications; user is expected to |
| 880 | * dequeue from the queue based on polling or other user-defined |
| 881 | * method |
| 882 | * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN |
| 883 | * notifications to the specified DPIO; user is expected to dequeue |
| 884 | * from the queue only after notification is received |
| 885 | * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate |
| 886 | * FQDAN notifications, but is connected to the specified DPCON |
| 887 | * object; user is expected to dequeue from the DPCON channel |
| 888 | */ |
| 889 | enum dpni_dest { |
| 890 | DPNI_DEST_NONE = 0, |
| 891 | DPNI_DEST_DPIO = 1, |
| 892 | DPNI_DEST_DPCON = 2 |
| 893 | }; |
| 894 | |
| 895 | /** |
| 896 | * struct dpni_dest_cfg - Structure representing DPNI destination parameters |
| 897 | * @dest_type: Destination type |
| 898 | * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type |
| 899 | * @priority: Priority selection within the DPIO or DPCON channel; valid values |
| 900 | * are 0-1 or 0-7, depending on the number of priorities in that |
| 901 | * channel; not relevant for 'DPNI_DEST_NONE' option |
| 902 | */ |
| 903 | struct dpni_dest_cfg { |
| 904 | enum dpni_dest dest_type; |
| 905 | int dest_id; |
| 906 | uint8_t priority; |
| 907 | }; |
| 908 | |
| 909 | /* DPNI queue modification options */ |
| 910 | |
| 911 | /* Select to modify the user's context associated with the queue */ |
| 912 | #define DPNI_QUEUE_OPT_USER_CTX 0x00000001 |
| 913 | /* Select to modify the queue's destination */ |
| 914 | #define DPNI_QUEUE_OPT_DEST 0x00000002 |
| 915 | |
| 916 | /** |
| 917 | * struct dpni_queue_cfg - Structure representing queue configuration |
| 918 | * @options: Flags representing the suggested modifications to the queue; |
| 919 | * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags |
| 920 | * @user_ctx: User context value provided in the frame descriptor of each |
| 921 | * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX' |
| 922 | * is contained in 'options' |
| 923 | * @dest_cfg: Queue destination parameters; |
| 924 | * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options' |
| 925 | */ |
| 926 | struct dpni_queue_cfg { |
| 927 | uint32_t options; |
| 928 | uint64_t user_ctx; |
| 929 | struct dpni_dest_cfg dest_cfg; |
| 930 | }; |
| 931 | |
| 932 | /** |
| 933 | * struct dpni_queue_attr - Structure representing queue attributes |
| 934 | * @user_ctx: User context value provided in the frame descriptor of each |
| 935 | * dequeued frame |
| 936 | * @dest_cfg: Queue destination configuration |
| 937 | * @fqid: Virtual fqid value to be used for dequeue operations |
| 938 | */ |
| 939 | struct dpni_queue_attr { |
| 940 | uint64_t user_ctx; |
| 941 | struct dpni_dest_cfg dest_cfg; |
| 942 | uint32_t fqid; |
| 943 | }; |
| 944 | |
| 945 | /* DPNI Tx flow modification options */ |
| 946 | |
| 947 | /* Select to modify the settings for dedicate Tx confirmation/error */ |
| 948 | #define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001 |
| 949 | /*!< Select to modify the Tx confirmation and/or error setting */ |
| 950 | #define DPNI_TX_FLOW_OPT_ONLY_TX_ERROR 0x00000002 |
| 951 | /*!< Select to modify the queue configuration */ |
| 952 | #define DPNI_TX_FLOW_OPT_QUEUE 0x00000004 |
| 953 | /*!< Select to modify the L3 checksum generation setting */ |
| 954 | #define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010 |
| 955 | /*!< Select to modify the L4 checksum generation setting */ |
| 956 | #define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020 |
| 957 | |
| 958 | /** |
| 959 | * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration |
| 960 | * @options: Flags representing the suggested modifications to the Tx flow; |
| 961 | * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags |
| 962 | * @conf_err_cfg: Tx confirmation and error configuration; these settings are |
| 963 | * ignored if 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' was set at |
| 964 | * DPNI creation |
| 965 | * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable; |
| 966 | * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in |
| 967 | * 'options' |
| 968 | * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable; |
| 969 | * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in |
| 970 | * 'options' |
| 971 | */ |
| 972 | struct dpni_tx_flow_cfg { |
| 973 | uint32_t options; |
| 974 | /** |
| 975 | * struct cnf_err_cfg - Tx confirmation and error configuration |
| 976 | * @use_default_queue: Set to '1' to use the common (default) Tx |
| 977 | * confirmation and error queue; Set to '0' to use the |
| 978 | * private Tx confirmation and error queue; valid only if |
| 979 | * 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in |
| 980 | * 'options' |
| 981 | * @errors_only: Set to '1' to report back only error frames; |
| 982 | * Set to '0' to confirm transmission/error for all |
| 983 | * transmitted frames; |
| 984 | * valid only if 'DPNI_TX_FLOW_OPT_ONLY_TX_ERROR' is |
| 985 | * contained in 'options' and 'use_default_queue = 0'; |
| 986 | * @queue_cfg: Queue configuration; valid only if |
| 987 | * 'DPNI_TX_FLOW_OPT_QUEUE' is contained in 'options' |
| 988 | */ |
| 989 | struct { |
| 990 | int use_default_queue; |
| 991 | int errors_only; |
| 992 | struct dpni_queue_cfg queue_cfg; |
| 993 | } conf_err_cfg; |
| 994 | int l3_chksum_gen; |
| 995 | int l4_chksum_gen; |
| 996 | }; |
| 997 | |
| 998 | /** |
| 999 | * dpni_set_tx_flow() - Set Tx flow configuration |
| 1000 | * @mc_io: Pointer to MC portal's I/O object |
| 1001 | * @token: Token of DPNI object |
| 1002 | * @flow_id: Provides (or returns) the sender's flow ID; |
| 1003 | * for each new sender set (*flow_id) to |
| 1004 | * 'DPNI_NEW_FLOW_ID' to generate a new flow_id; |
| 1005 | * this ID should be used as the QDBIN argument |
| 1006 | * in enqueue operations |
| 1007 | * @cfg: Tx flow configuration |
| 1008 | * |
| 1009 | * Return: '0' on Success; Error code otherwise. |
| 1010 | */ |
| 1011 | int dpni_set_tx_flow(struct fsl_mc_io *mc_io, |
| 1012 | uint16_t token, |
| 1013 | uint16_t *flow_id, |
| 1014 | const struct dpni_tx_flow_cfg *cfg); |
| 1015 | |
| 1016 | /** |
| 1017 | * struct dpni_tx_flow_attr - Structure representing Tx flow attributes |
| 1018 | * @conf_err_attr: Tx confirmation and error attributes |
| 1019 | * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled |
| 1020 | * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled |
| 1021 | */ |
| 1022 | struct dpni_tx_flow_attr { |
| 1023 | /** |
| 1024 | * struct conf_err_attr - Tx confirmation and error attributes |
| 1025 | * @use_default_queue: '1' if using common (default) Tx confirmation and |
| 1026 | * error queue; |
| 1027 | * '0' if using private Tx confirmation and error |
| 1028 | * queue |
| 1029 | * @errors_only: '1' if only error frames are reported back; '0' if all |
| 1030 | * transmitted frames are confirmed |
| 1031 | * @queue_attr: Queue attributes |
| 1032 | */ |
| 1033 | struct { |
| 1034 | int use_default_queue; |
| 1035 | int errors_only; |
| 1036 | struct dpni_queue_attr queue_attr; |
| 1037 | } conf_err_attr; |
| 1038 | int l3_chksum_gen; |
| 1039 | int l4_chksum_gen; |
| 1040 | }; |
| 1041 | |
| 1042 | /** |
| 1043 | * dpni_get_tx_flow() - Get Tx flow attributes |
| 1044 | * @mc_io: Pointer to MC portal's I/O object |
| 1045 | * @token: Token of DPNI object |
| 1046 | * @flow_id: The sender's flow ID, as returned by the |
| 1047 | * dpni_set_tx_flow() function |
| 1048 | * @attr: Returned Tx flow attributes |
| 1049 | * |
| 1050 | * Return: '0' on Success; Error code otherwise. |
| 1051 | */ |
| 1052 | int dpni_get_tx_flow(struct fsl_mc_io *mc_io, |
| 1053 | uint16_t token, |
| 1054 | uint16_t flow_id, |
| 1055 | struct dpni_tx_flow_attr *attr); |
| 1056 | |
| 1057 | /** |
| 1058 | * dpni_set_rx_flow() - Set Rx flow configuration |
| 1059 | * @mc_io: Pointer to MC portal's I/O object |
| 1060 | * @token: Token of DPNI object |
| 1061 | * @tc_id: Traffic class selection (0-7); |
| 1062 | * use 'DPNI_ALL_TCS' to set all TCs and all flows |
| 1063 | * @flow_id Rx flow id within the traffic class; use |
| 1064 | * 'DPNI_ALL_TC_FLOWS' to set all flows within |
| 1065 | * this tc_id; ignored if tc_id is set to |
| 1066 | * 'DPNI_ALL_TCS'; |
| 1067 | * @cfg: Rx flow configuration |
| 1068 | * |
| 1069 | * Return: '0' on Success; Error code otherwise. |
| 1070 | */ |
| 1071 | int dpni_set_rx_flow(struct fsl_mc_io *mc_io, |
| 1072 | uint16_t token, |
| 1073 | uint8_t tc_id, |
| 1074 | uint16_t flow_id, |
| 1075 | const struct dpni_queue_cfg *cfg); |
| 1076 | |
| 1077 | /** |
| 1078 | * dpni_get_rx_flow() - Get Rx flow attributes |
| 1079 | * @mc_io: Pointer to MC portal's I/O object |
| 1080 | * @token: Token of DPNI object |
| 1081 | * @tc_id: Traffic class selection (0-7) |
| 1082 | * @flow_id: Rx flow id within the traffic class |
| 1083 | * @attr: Returned Rx flow attributes |
| 1084 | * |
| 1085 | * Return: '0' on Success; Error code otherwise. |
| 1086 | */ |
| 1087 | int dpni_get_rx_flow(struct fsl_mc_io *mc_io, |
| 1088 | uint16_t token, |
| 1089 | uint8_t tc_id, |
| 1090 | uint16_t flow_id, |
| 1091 | struct dpni_queue_attr *attr); |
| 1092 | |
| 1093 | #endif /* _FSL_DPNI_H */ |