From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60051.outbound.protection.outlook.com [40.107.6.51]) by dpdk.org (Postfix) with ESMTP id 4796E4F9B for ; Tue, 16 Oct 2018 10:14:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DPVfc7NyuEEWoIoPRG0cZJB7TyI2zEOWwbTNFJGElSc=; b=UhUABYdc/j5TclSmYzopOnte4XOuKSwVcU2A7tpQQRqHvskzocJZJlCcWTJ0dbzaN/KwtaTjqb2Vj9zqHRt36ZFFW4d+NQprD3mb9xhOP+7n0pWYDFjzdvVqJNILZJ7JtInC67qDDSJQLab+cQpRs6L+DghQ/xwuejkTIpga3yU= Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com (10.168.9.17) by DB6PR0501MB2168.eurprd05.prod.outlook.com (10.168.55.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.31; Tue, 16 Oct 2018 08:14:31 +0000 Received: from DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913]) by DB6PR0501MB2023.eurprd05.prod.outlook.com ([fe80::b1fb:bad3:b5b1:f913%3]) with mapi id 15.20.1250.020; Tue, 16 Oct 2018 08:14:31 +0000 From: Jack Min To: Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [PATCH v6 3/3] net/mlx5: rewrite TTL by E-Switch Thread-Index: AQHUZShD/D1lNjUWTE23OqS/6iIXzw== Date: Tue, 16 Oct 2018 08:14:30 +0000 Message-ID: <20181016081350.24765-4-jackmin@mellanox.com> References: <20181013032348.26380-1-jackmin@mellanox.com> <20181016081350.24765-1-jackmin@mellanox.com> In-Reply-To: <20181016081350.24765-1-jackmin@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR01CA0012.apcprd01.prod.exchangelabs.com (2603:1096:203:92::24) To DB6PR0501MB2023.eurprd05.prod.outlook.com (2603:10a6:4:6::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=jackmin@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [118.201.220.138] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0501MB2168; 6:VsjyjPsmSNfPS5U0SoBcWbDLmCHri2wZPF18ModLywZsDBOWCcl/qeVMy3I9Jajtpwgibgd5TXiC4vcoN5OR9qEdvusjYbVS11McfbffqndI+qGZw4tA0HW3MhwIkAoUKVog7NSFhYtEfpQBn1+Uw2EESfGYgS0dWy6LpV/humb+6gtNttVUkyJJLhT6A/Qt25iILVOEfEV+SLA0c6bmT0e/JaLkqY++/yOyTEFrGAOzQ1UU/jRyNTS16SlonOhIXr+5xPrGIfLEk9i3xv2WOdUg+Lf1aRwRZla8T5KJR+3yPLDLnDbkn/57vTmaEc0uR9bqe9dleMsJR4RLE7jxnG+OAwJk4oSyrwR1jW1gwp/D4jYMHXXSBxjpywjmsw7dcZ5nUP6dldlMdf4Rbos7lAnhD4CGe8DUCe0r9qUfxP7kWcxghnuMN55KmrM48ypdiG3RsdqJStvnybNvyFF1zA==; 5:hQOGutY1YNxASnd0M63fewPfI69KN17tcXHKvFFSjeSdQZDOUnaa1dO7xftXPXQaKYYDfXjMDpffBdxnWBaOFyiYwfhTJ1yw3aZAa+m9wrmq4yyBT4XJOcS6T6jp/x6N/m04Fl6dqG1CD9NYoqyPXe/JziG2wZUBUyXFV2iR9G4=; 7:9cgfWSNOdA7FX2+zc4MS93ttT7iM50dZZZBhwSIngivAoRYwM8he9H4t1fiwtljhf/fAnQPiyZvc068kPnW0agGlxalrp52va2aANE4EIJWEVmfwB9KNRj3N24Z9xXLji8vd3YXZ6KykL2vl5Tgzx04kCGE4QYvufUSXF0nWMPODq4LcOQ6kcWNkQRQJhJszdw+zxIMng2gpyXob8y9/e84EHU+yKo85yZ7Uo/q8GYSsy/QsA5MdzRuoELK5LVYI x-ms-office365-filtering-correlation-id: c6e7b5fd-0229-4ac5-5180-08d6333f65e0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2168; x-ms-traffictypediagnostic: DB6PR0501MB2168: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991067); SRVR:DB6PR0501MB2168; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2168; x-forefront-prvs: 0827D7ACB9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(136003)(39860400002)(366004)(199004)(189003)(1076002)(386003)(52116002)(76176011)(6506007)(4326008)(66066001)(25786009)(6486002)(6436002)(6512007)(486006)(476003)(2616005)(11346002)(446003)(5660300001)(36756003)(2900100001)(102836004)(53936002)(26005)(316002)(186003)(68736007)(110136005)(85306007)(99286004)(86362001)(7736002)(305945005)(6636002)(478600001)(14454004)(81166006)(8676002)(81156014)(97736004)(8936002)(14444005)(256004)(2906002)(105586002)(106356001)(71190400001)(71200400001)(5250100002)(3846002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2168; H:DB6PR0501MB2023.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: /tAEaTLbB1Z0A2pGCcDx9l2kdB4wKijMT3VEau8X4Tmo6ln2zUWKR90KBuC+AGC3iVowuF5fVfpT60ZvEKTevcXhbGbiV1qbf0tUGeoBeuGEVznYRojMxeu6PWylx7lsblrN06JT+j+eKQn/zsz3Sqgv3FjzpIKgzSZqpw6BkNQjqKFgGpKW685GdIgnQ6eB77uTCaDvBcrT+tC/bed1hWPwLj3KeWg7ljJCBnF8e42l/FyjGKIbjF3I/jewa1inQfJ/y55H4pJUUMcUo/XHkD25R8ErzBrd4puzZU/xsOY7x20D9rjK2tZIU+QeWOiX8aR1MvHTnuz9nCJFLGi0LNBWdSBTdBEM66HoOCQIxSA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6e7b5fd-0229-4ac5-5180-08d6333f65e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2018 08:14:30.8813 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2168 Subject: [dpdk-dev] [PATCH v6 3/3] net/mlx5: rewrite TTL by E-Switch 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: Tue, 16 Oct 2018 08:14:32 -0000 Offload following modify TTL actions to E-Switch via TC-Flower driver - RTE_FLOW_ACTION_TYPE_SET_TTL - RTE_FLOW_ACTION_TYPE_DEC_TTL The corresponding IP protocol rte_flow_item_ipv[4|6] must be present in rte_flow pattern otherwith PMD return error The example testpmd commands are: flow create 0 transfer ingress pattern eth / ipv4 / udp dst is 7000 / end actions dec_ttl / port_id id 1 / end flow create 0 transfer ingress pattern eth / ipv4 / udp dst is 7001 / end actions set_ttl ttl_value 10 / port_id id 1 / end Signed-off-by: Xiaoyu Min Acked-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_tcf.c | 83 +++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 094f6668f..cccafe52d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -85,6 +85,8 @@ #define MLX5_FLOW_ACTION_SET_TP_SRC (1u << 15) #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16) #define MLX5_FLOW_ACTION_JUMP (1u << 17) +#define MLX5_FLOW_ACTION_SET_TTL (1u << 18) +#define MLX5_FLOW_ACTION_DEC_TTL (1u << 19) =20 #define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_= tcf.c index 4b51a854e..3adcf189e 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -231,6 +231,10 @@ struct tc_pedit_sel { #define TP_PORT_LEN 2 /* Transport Port (UDP/TCP) Length */ #endif =20 +#ifndef TTL_LEN +#define TTL_LEN 1 +#endif + /** Empty masks for known item types. */ static const union { struct rte_flow_item_port_id port_id; @@ -319,12 +323,14 @@ struct flow_tcf_ptoi { #define MLX5_TCF_PEDIT_ACTIONS \ (MLX5_FLOW_ACTION_SET_IPV4_SRC | MLX5_FLOW_ACTION_SET_IPV4_DST | \ MLX5_FLOW_ACTION_SET_IPV6_SRC | MLX5_FLOW_ACTION_SET_IPV6_DST | \ - MLX5_FLOW_ACTION_SET_TP_SRC | MLX5_FLOW_ACTION_SET_TP_DST) + MLX5_FLOW_ACTION_SET_TP_SRC | MLX5_FLOW_ACTION_SET_TP_DST | \ + MLX5_FLOW_ACTION_SET_TTL | MLX5_FLOW_ACTION_DEC_TTL) =20 #define MLX5_TCF_CONFIG_ACTIONS \ (MLX5_FLOW_ACTION_PORT_ID | MLX5_FLOW_ACTION_JUMP | \ MLX5_FLOW_ACTION_OF_PUSH_VLAN | MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \ - MLX5_FLOW_ACTION_OF_SET_VLAN_PCP | MLX5_TCF_PEDIT_ACTIONS) + MLX5_FLOW_ACTION_OF_SET_VLAN_PCP | \ + (MLX5_TCF_PEDIT_ACTIONS & ~MLX5_FLOW_ACTION_DEC_TTL)) =20 #define MAX_PEDIT_KEYS 128 #define SZ_PEDIT_KEY_VAL 4 @@ -344,6 +350,46 @@ struct pedit_parser { }; =20 =20 +/** + * Set pedit key of decrease/set ttl + * + * @param[in] actions + * pointer to action specification + * @param[in,out] p_parser + * pointer to pedit_parser + * @param[in] item_flags + * flags of all items presented + */ +static void +flow_tcf_pedit_key_set_dec_ttl(const struct rte_flow_action *actions, + struct pedit_parser *p_parser, + uint64_t item_flags) +{ + int idx =3D p_parser->sel.nkeys; + + p_parser->keys[idx].mask =3D 0xFFFFFF00; + if (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV4) { + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_IP4; + p_parser->keys[idx].off =3D + offsetof(struct ipv4_hdr, time_to_live); + } + if (item_flags & MLX5_FLOW_LAYER_OUTER_L3_IPV6) { + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_IP6; + p_parser->keys[idx].off =3D + offsetof(struct ipv6_hdr, hop_limits); + } + if (actions->type =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TTL) { + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_ADD; + p_parser->keys[idx].val =3D 0x000000FF; + } else { + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_SET; + p_parser->keys[idx].val =3D + (__u32)((const struct rte_flow_action_set_ttl *) + actions->conf)->ttl_value; + } + p_parser->sel.nkeys =3D (++idx); +} + /** * Set pedit key of transport (TCP/UDP) port value * @@ -479,6 +525,11 @@ flow_tcf_create_pedit_mnl_msg(struct nlmsghdr *nl, flow_tcf_pedit_key_set_tp_port(*actions, &p_parser, item_flags); break; + case RTE_FLOW_ACTION_TYPE_SET_TTL: + case RTE_FLOW_ACTION_TYPE_DEC_TTL: + flow_tcf_pedit_key_set_dec_ttl(*actions, + &p_parser, item_flags); + break; default: goto pedit_mnl_msg_done; } @@ -559,6 +610,14 @@ flow_tcf_get_pedit_actions_size(const struct rte_flow_= action **actions, keys +=3D NUM_OF_PEDIT_KEYS(TP_PORT_LEN); flags |=3D MLX5_FLOW_ACTION_SET_TP_DST; break; + case RTE_FLOW_ACTION_TYPE_SET_TTL: + keys +=3D NUM_OF_PEDIT_KEYS(TTL_LEN); + flags |=3D MLX5_FLOW_ACTION_SET_TTL; + break; + case RTE_FLOW_ACTION_TYPE_DEC_TTL: + keys +=3D NUM_OF_PEDIT_KEYS(TTL_LEN); + flags |=3D MLX5_FLOW_ACTION_DEC_TTL; + break; default: goto get_pedit_action_size_done; } @@ -1096,6 +1155,12 @@ flow_tcf_validate(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_SET_TP_DST: current_action_flag =3D MLX5_FLOW_ACTION_SET_TP_DST; break; + case RTE_FLOW_ACTION_TYPE_SET_TTL: + current_action_flag =3D MLX5_FLOW_ACTION_SET_TTL; + break; + case RTE_FLOW_ACTION_TYPE_DEC_TTL: + current_action_flag =3D MLX5_FLOW_ACTION_DEC_TTL; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -1198,6 +1263,16 @@ flow_tcf_validate(struct rte_eth_dev *dev, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, "no fate action is found"); + if (action_flags & + (MLX5_FLOW_ACTION_SET_TTL | MLX5_FLOW_ACTION_DEC_TTL)) { + if (!(item_flags & + (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | + MLX5_FLOW_LAYER_OUTER_L3_IPV6))) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "no IP found in pattern"); + } return 0; } =20 @@ -1357,6 +1432,8 @@ flow_tcf_get_actions_and_size(const struct rte_flow_a= ction actions[], case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: case RTE_FLOW_ACTION_TYPE_SET_TP_DST: + case RTE_FLOW_ACTION_TYPE_SET_TTL: + case RTE_FLOW_ACTION_TYPE_DEC_TTL: size +=3D flow_tcf_get_pedit_actions_size(&actions, &flags); break; @@ -1933,6 +2010,8 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct ml= x5_flow *dev_flow, case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST: case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: case RTE_FLOW_ACTION_TYPE_SET_TP_DST: + case RTE_FLOW_ACTION_TYPE_SET_TTL: + case RTE_FLOW_ACTION_TYPE_DEC_TTL: na_act_index =3D mnl_attr_nest_start(nlh, na_act_index_cur++); flow_tcf_create_pedit_mnl_msg(nlh, --=20 2.17.1