From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id 1873010CB3 for ; Wed, 21 Dec 2016 15:52:59 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id g23so24637702wme.1 for ; Wed, 21 Dec 2016 06:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=U2/wFZinybkyB6sOzb0oAJ+LsKwO+3hRB8iQU+0hf6k=; b=LFxta1ewD3xcFly7iO8NHoAzd3PveCg3I8thXPOZ1t4dzwKHcleZ0qRU56NlfVj/ch P3WC+OJnyssEGajsdHQMGyp0KHOsez1L34uT+sBJyc9VoovhLkA+A7IEqtpzmhUPxhV2 qiK9Oa7hmv9o9YIVRCTzShwNuhY7E9V4eljT+r/DnS5I1N1ygWlT2hDMoCeKyJIu/E83 CCVXbv9oweVI/cvm2IK2f0BUkqskcXlyia68Vv7oUVGnhxw/zXP8Gw9H37tac5bW4SbM 9nm9EH+zJyoQosRd1kRoeDiLjSkX2Jg8ajr9VK/UZk8BG3A/ihoDBJEXAL9FrRxsa/n4 7xcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=U2/wFZinybkyB6sOzb0oAJ+LsKwO+3hRB8iQU+0hf6k=; b=q/TcIqnixszzvP+O9AX0WbZAXHChzBToBi4VWyRq9oF00VVdPVZsVy4WOjkV8E92jX /geoxzaTNa4wtJpkAOCQrR8xXGgCpSjpR3zdvZifKSb7UbN8t++UgpiwvrGmxsdfy982 T2fTwEJXByVs3pPrD6+t59/dEzZ0rqUwZ7R5kUV82nUWxYcs3S/IQ61gKo/lPG2/H5w/ mfoctIa3KWcAkz0HHYA+wNZvTzIZjntYRhP3Hw8f9QSQZYTCeKGdWlz7UvnGGeCFoTTv 7AEbVaCh2ON8zgd0N6iGzMgigwvqYel28fTHWWrjBaRzQoU+VRTjJX07CWwq5K2/YjNN 2JRQ== X-Gm-Message-State: AIkVDXIeQqMEdhHaQ/SNpccRijLCCF7XzkxV3ksbTBEvLzwDl8PhmgX5gjfEDUThNB2JGIr6 X-Received: by 10.28.73.136 with SMTP id w130mr7078371wma.82.1482331978332; Wed, 21 Dec 2016 06:52:58 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id c81sm27445643wmf.22.2016.12.21.06.52.56 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 21 Dec 2016 06:52:57 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Wed, 21 Dec 2016 15:51:39 +0100 Message-Id: <9b10d290bd806d295b9f6ae150c3a3ac9b4ad80c.1482331076.git.adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 23/26] app/testpmd: add various actions to flow command 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: , X-List-Received-Date: Wed, 21 Dec 2016 14:52:59 -0000 - MARK: attach 32 bit value to packets. - FLAG: flag packets. - DROP: drop packets. - COUNT: enable counters for a rule. - PF: redirect packets to physical device function. - VF: redirect packets to virtual device function. Signed-off-by: Adrien Mazarguil Acked-by: Olga Shern --- app/test-pmd/cmdline_flow.c | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 259e9eb..a4e8ebe 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -153,6 +153,15 @@ enum index { ACTION_END, ACTION_VOID, ACTION_PASSTHRU, + ACTION_MARK, + ACTION_MARK_ID, + ACTION_FLAG, + ACTION_DROP, + ACTION_COUNT, + ACTION_PF, + ACTION_VF, + ACTION_VF_ORIGINAL, + ACTION_VF_ID, }; /** Size of pattern[] field in struct rte_flow_item_raw. */ @@ -476,6 +485,25 @@ static const enum index next_action[] = { ACTION_END, ACTION_VOID, ACTION_PASSTHRU, + ACTION_MARK, + ACTION_FLAG, + ACTION_DROP, + ACTION_COUNT, + ACTION_PF, + ACTION_VF, + ZERO, +}; + +static const enum index action_mark[] = { + ACTION_MARK_ID, + ACTION_NEXT, + ZERO, +}; + +static const enum index action_vf[] = { + ACTION_VF_ORIGINAL, + ACTION_VF_ID, + ACTION_NEXT, ZERO, }; @@ -487,6 +515,8 @@ static int parse_vc(struct context *, const struct token *, void *, unsigned int); static int parse_vc_spec(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_vc_conf(struct context *, const struct token *, + const char *, unsigned int, void *, unsigned int); static int parse_destroy(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1112,6 +1142,70 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, + [ACTION_MARK] = { + .name = "mark", + .help = "attach 32 bit value to packets", + .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)), + .next = NEXT(action_mark), + .call = parse_vc, + }, + [ACTION_MARK_ID] = { + .name = "id", + .help = "32 bit value to return with packets", + .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)), + .call = parse_vc_conf, + }, + [ACTION_FLAG] = { + .name = "flag", + .help = "flag packets", + .priv = PRIV_ACTION(FLAG, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_DROP] = { + .name = "drop", + .help = "drop packets (note: passthru has priority)", + .priv = PRIV_ACTION(DROP, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_COUNT] = { + .name = "count", + .help = "enable counters for this rule", + .priv = PRIV_ACTION(COUNT, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_PF] = { + .name = "pf", + .help = "redirect packets to physical device function", + .priv = PRIV_ACTION(PF, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_VF] = { + .name = "vf", + .help = "redirect packets to virtual device function", + .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)), + .next = NEXT(action_vf), + .call = parse_vc, + }, + [ACTION_VF_ORIGINAL] = { + .name = "original", + .help = "use original VF ID if possible", + .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf, + original, 1)), + .call = parse_vc_conf, + }, + [ACTION_VF_ID] = { + .name = "id", + .help = "VF ID to redirect packets to", + .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)), + .call = parse_vc_conf, + }, }; /** Remove and return last entry from argument stack. */ @@ -1446,6 +1540,33 @@ parse_vc_spec(struct context *ctx, const struct token *token, return len; } +/** Parse action configuration field. */ +static int +parse_vc_conf(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; + + (void)size; + /* Token name must match. */ + if (parse_default(ctx, token, str, len, NULL, 0) < 0) + return -1; + /* Nothing else to do if there is no buffer. */ + if (!out) + return len; + 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; + /* Update configuration pointer. */ + action->conf = ctx->object; + return len; +} + /** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token, -- 2.1.4