| 308 | } |
| 309 | |
| 310 | static int |
| 311 | create_default_flow(const struct mcs_test_vector *td, uint16_t portid, |
| 312 | enum rte_security_macsec_direction dir, void *sess) |
| 313 | { |
| 314 | struct rte_flow_action action[2]; |
| 315 | struct rte_flow_item pattern[2]; |
| 316 | struct rte_flow_attr attr = {0}; |
| 317 | struct rte_flow_error err; |
| 318 | struct rte_flow *flow; |
| 319 | struct rte_flow_item_eth eth = { .hdr.ether_type = 0, }; |
| 320 | static const struct rte_flow_item_eth eth_mask = { |
| 321 | .hdr.dst_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00", |
| 322 | .hdr.src_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00", |
| 323 | .hdr.ether_type = RTE_BE16(0x0000), |
| 324 | }; |
| 325 | |
| 326 | int ret; |
| 327 | |
| 328 | eth.has_vlan = 0; |
| 329 | if (dir == RTE_SECURITY_MACSEC_DIR_TX) |
| 330 | memcpy(ð.hdr, td->plain_pkt.data, RTE_ETHER_HDR_LEN); |
| 331 | else |
| 332 | memcpy(ð.hdr, td->secure_pkt.data, RTE_ETHER_HDR_LEN); |
| 333 | |
| 334 | pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH; |
| 335 | pattern[0].spec = ð |
| 336 | pattern[0].mask = ð_mask; |
| 337 | pattern[0].last = NULL; |
| 338 | pattern[1].type = RTE_FLOW_ITEM_TYPE_END; |
| 339 | |
| 340 | action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY; |
| 341 | action[0].conf = sess; |
| 342 | action[1].type = RTE_FLOW_ACTION_TYPE_END; |
| 343 | action[1].conf = NULL; |
| 344 | |
| 345 | attr.ingress = (dir == RTE_SECURITY_MACSEC_DIR_RX) ? 1 : 0; |
| 346 | attr.egress = (dir == RTE_SECURITY_MACSEC_DIR_TX) ? 1 : 0; |
| 347 | |
| 348 | ret = rte_flow_validate(portid, &attr, pattern, action, &err); |
| 349 | if (ret) { |
| 350 | printf("\nValidate flow failed, ret = %d\n", ret); |
| 351 | return -1; |
| 352 | } |
| 353 | flow = rte_flow_create(portid, &attr, pattern, action, &err); |
| 354 | if (flow == NULL) { |
| 355 | printf("\nDefault flow rule create failed\n"); |
| 356 | return -1; |
| 357 | } |
| 358 | |
| 359 | if (dir == RTE_SECURITY_MACSEC_DIR_TX) |
| 360 | default_tx_flow[portid] = flow; |
| 361 | else |
| 362 | default_rx_flow[portid] = flow; |
| 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | static void |
no test coverage detected