From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1F287A0566; Tue, 10 Mar 2020 17:06:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E2D0F1BFFF; Tue, 10 Mar 2020 17:06:44 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 7EA751BFFC for ; Tue, 10 Mar 2020 17:06:43 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02AFjsIJ013056; Tue, 10 Mar 2020 09:06:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=Vk0UGPCatum7KyRhpzuL6O51MhVeOQhDFfqh/HBHwrs=; b=yAXkGknM2P1ZMMPMCNCCwsPYoqLgQVlzmWN5avfrmSYLMFm4wHq9/pk/xNnN2ItRba5P u6TYYyQdNAFbVffoRWNxixDTcG43sTI3kouY+GRm8OSKSxADGbyqHqXAvnAidUDy3X4k 9saglaNZdEBFRLSv8XUVqOX2FZJX9ohJAFU0ITa06X9Is+pQ+pe5aIDFcb3fYiUvDF87 4/u+z0yAxNtkvuxPr0PDQl0JP9R1WQIt49yhUE9ij2xgPzrH9wh7cZYHUAysPLUQZy28 naomXk5DSnd50eiM0XlqAfC0RHRAFdv0K85/lVo7qUT+zZgcoklTo6etRVUk9nbAZMhD Lw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2yp04fmc04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 10 Mar 2020 09:06:42 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 10 Mar 2020 09:06:40 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 10 Mar 2020 09:06:40 -0700 Received: from localhost.localdomain (unknown [10.28.34.15]) by maili.marvell.com (Postfix) with ESMTP id 615013F703F; Tue, 10 Mar 2020 09:06:37 -0700 (PDT) From: To: Ori Kam , Wenzhuo Lu , "Jingjing Wu" , Bernard Iremonger , John McNamara , Marko Kovacevic , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko CC: , Kiran Kumar K Date: Tue, 10 Mar 2020 21:36:09 +0530 Message-ID: <20200310160609.7434-1-kirankumark@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-03-10_10:2020-03-10, 2020-03-10 signatures=0 Subject: [dpdk-dev] [PATCH] ethdev: add DBDF action to RTE Flow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kiran Kumar K Adding suuport to DBDF action in the RTE Flow. Application can specify the dbdf value using rte_flow_action_dbdf. Matched traffic will be sent to specified PCI DBDF device. Signed-off-by: Kiran Kumar K --- app/test-pmd/cmdline_flow.c | 64 ++++++++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 19 +++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 16 ++++++++ 4 files changed, 100 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a78154502..c318b4a27 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -342,8 +342,17 @@ enum index { ACTION_SET_IPV4_DSCP_VALUE, ACTION_SET_IPV6_DSCP, ACTION_SET_IPV6_DSCP_VALUE, + ACTION_DBDF, }; +#define DBDF_KEY_LENGTH 20 + +struct action_dbdf_data { + struct rte_flow_action_dbdf conf; + uint8_t dbdf_value[DBDF_KEY_LENGTH]; +}; + + /** Maximum size for pattern in struct rte_flow_item_raw. */ #define ITEM_RAW_PATTERN_SIZE 40 @@ -1144,6 +1153,7 @@ static const enum index next_action[] = { ACTION_SET_META, ACTION_SET_IPV4_DSCP, ACTION_SET_IPV6_DSCP, + ACTION_DBDF, ZERO, }; @@ -1369,6 +1379,11 @@ static const enum index action_set_ipv6_dscp[] = { ZERO, }; +static const enum index action_dbdf[] = { + ACTION_NEXT, + ZERO, +}; + static int parse_set_raw_encap_decap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1421,6 +1436,9 @@ static int parse_vc_action_mplsoudp_encap(struct context *, static int parse_vc_action_mplsoudp_decap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_action_dbdf_value(struct context *, + const struct token *, const char *, + unsigned int, void *, unsigned int); static int parse_vc_action_raw_encap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -3684,6 +3702,18 @@ static const struct token token_list[] = { (struct rte_flow_action_set_dscp, dscp)), .call = parse_vc_conf, }, + [ACTION_DBDF] = { + .name = "dbdf", + .help = "set DBDF value", + .next = NEXT(action_dbdf, NEXT_ENTRY(STRING)), + .priv = PRIV_ACTION(DBDF, sizeof(struct action_dbdf_data)), + .args = ARGS(ARGS_ENTRY_ARB(0, 0), + ARGS_ENTRY_ARB(0, sizeof(uint8_t)), + ARGS_ENTRY_ARB( + offsetof(struct action_dbdf_data, dbdf_value), + DBDF_KEY_LENGTH)), + .call = parse_vc_action_dbdf_value, + }, }; /** Remove and return last entry from argument stack. */ @@ -5064,6 +5094,40 @@ parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token, return len; } +static int +parse_vc_action_dbdf_value(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct buffer *out = buf; + struct rte_flow_action *action; + struct action_dbdf_data *action_dbdf_data = NULL; + int ret; + + ret = parse_vc(ctx, token, str, len, buf, size); + if (ret < 0) + return ret; + /* Nothing else to do if there is no buffer. */ + if (!out) + return ret; + if (!out->args.vc.actions_n) + return -1; + action = &out->args.vc.actions[out->args.vc.actions_n - 1]; + /* Point to selected object. */ + ctx->object = out->args.vc.data; + ctx->objmask = NULL; + /* Copy the headers to the buffer. */ + action_dbdf_data = ctx->object; + *action_dbdf_data = (struct action_dbdf_data) { + .conf = (struct rte_flow_action_dbdf){ + .dbdf_value = action_dbdf_data->dbdf_value, + }, + .dbdf_value = {}, + }; + action->conf = &action_dbdf_data->conf; + return ret; +} + static int parse_vc_action_raw_encap(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 41c147913..b900e283c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2616,6 +2616,25 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. | ``dscp`` | DSCP in low 6 bits, rest ignore | +-----------+---------------------------------+ +Action: ``DBDF`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Set DBDF value. + +Send traffic to specified PCI DBDF device. + +.. _table_rte_flow_action_dbdf: + +.. table:: DBDF + + +-----------------+----------------------------+ + | Field | Value | + +=================+============================+ + | ``length`` | DBDF length | + +-----------------+----------------------------+ + | ``dbdf_value`` | DBDF value | + +-----------------+----------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index a5ac1c7fb..6eada7785 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -172,6 +172,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(SET_META, sizeof(struct rte_flow_action_set_meta)), MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct rte_flow_action_set_dscp)), MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), + MK_FLOW_ACTION(DBDF, sizeof(struct rte_flow_action_dbdf)), }; int diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index b43238b45..b6029c282 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2082,6 +2082,22 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_dscp. */ RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, + + /** + * Send packet to specified PCIe device + */ + RTE_FLOW_ACTION_TYPE_DBDF, +}; + + +/** + * RTE_FLOW_ACTION_TYPE_DBDF + * + * Send the packet to specified PCI DBDF device + */ +struct rte_flow_action_dbdf { + uint8_t length; + const uint8_t *dbdf_value; }; /** -- 2.17.1