MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tap_flow_create

Function tap_flow_create

dpdk/drivers/net/tap/tap_flow.c:1367–1480  ·  view source on GitHub ↗

* Create a flow. * * @see rte_flow_create() * @see rte_flow_ops */

Source from the content-addressed store, hash-verified

1365 * @see rte_flow_ops
1366 */
1367static struct rte_flow *
1368tap_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;

Callers

nothing calls this directly

Calls 9

rte_flow_error_setFunction · 0.85
rte_zmallocFunction · 0.85
tc_init_msgFunction · 0.85
tap_flow_set_handleFunction · 0.85
priv_flow_processFunction · 0.85
tap_nl_sendFunction · 0.85
tap_nl_recv_ackFunction · 0.85
rte_freeFunction · 0.85
tap_flow_freeFunction · 0.85

Tested by

no test coverage detected