* Create a flow. * * @see rte_flow_create() * @see rte_flow_ops */
| 1365 | * @see rte_flow_ops |
| 1366 | */ |
| 1367 | static struct rte_flow * |
| 1368 | tap_flow_create(struct rte_eth_dev *dev, |
| 1369 | const struct rte_flow_attr *attr, |
| 1370 | const struct rte_flow_item items[], |
| 1371 | const struct rte_flow_action actions[], |
| 1372 | struct rte_flow_error *error) |
| 1373 | { |
| 1374 | struct pmd_internals *pmd = dev->data->dev_private; |
| 1375 | struct rte_flow *remote_flow = NULL; |
| 1376 | struct rte_flow *flow = NULL; |
| 1377 | struct nlmsg *msg = NULL; |
| 1378 | int err; |
| 1379 | |
| 1380 | if (!pmd->if_index) { |
| 1381 | rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, |
| 1382 | NULL, |
| 1383 | "can't create rule, ifindex not found"); |
| 1384 | goto fail; |
| 1385 | } |
| 1386 | /* |
| 1387 | * No rules configured through standard rte_flow should be set on the |
| 1388 | * priorities used by implicit rules. |
| 1389 | */ |
| 1390 | if ((attr->group == MAX_GROUP) && |
| 1391 | attr->priority > (MAX_PRIORITY - TAP_REMOTE_MAX_IDX)) { |
| 1392 | rte_flow_error_set( |
| 1393 | error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, |
| 1394 | NULL, "priority value too big"); |
| 1395 | goto fail; |
| 1396 | } |
| 1397 | flow = rte_zmalloc(__func__, sizeof(struct rte_flow), 0); |
| 1398 | if (!flow) { |
| 1399 | rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE, |
| 1400 | NULL, "cannot allocate memory for rte_flow"); |
| 1401 | goto fail; |
| 1402 | } |
| 1403 | msg = &flow->msg; |
| 1404 | tc_init_msg(msg, pmd->if_index, RTM_NEWTFILTER, |
| 1405 | NLM_F_REQUEST | NLM_F_ACK | NLM_F_EXCL | NLM_F_CREATE); |
| 1406 | msg->t.tcm_info = TC_H_MAKE(0, htons(ETH_P_ALL)); |
| 1407 | tap_flow_set_handle(flow); |
| 1408 | if (priv_flow_process(pmd, attr, items, actions, error, flow, 0)) |
| 1409 | goto fail; |
| 1410 | err = tap_nl_send(pmd->nlsk_fd, &msg->nh); |
| 1411 | if (err < 0) { |
| 1412 | rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, |
| 1413 | NULL, "couldn't send request to kernel"); |
| 1414 | goto fail; |
| 1415 | } |
| 1416 | err = tap_nl_recv_ack(pmd->nlsk_fd); |
| 1417 | if (err < 0) { |
| 1418 | TAP_LOG(ERR, |
| 1419 | "Kernel refused TC filter rule creation (%d): %s", |
| 1420 | errno, strerror(errno)); |
| 1421 | rte_flow_error_set(error, EEXIST, RTE_FLOW_ERROR_TYPE_HANDLE, |
| 1422 | NULL, |
| 1423 | "overlapping rules or Kernel too old for flower support"); |
| 1424 | goto fail; |
nothing calls this directly
no test coverage detected