From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yongseok Koh Subject: Re: [PATCH 3/3] net/mlx5: eswitch-modify MAC address actions Date: Wed, 3 Oct 2018 20:10:35 +0000 Message-ID: <20181003201026.GF26206@mtidpdk.mti.labs.mlnx> References: <20180925150340.25378-1-jackmin@mellanox.com> <20180925150340.25378-4-jackmin@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "ferruh.yigit@intel.com" , Shahaf Shuler , "dev@dpdk.org" To: Jack Min Return-path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60040.outbound.protection.outlook.com [40.107.6.40]) by dpdk.org (Postfix) with ESMTP id 6A8D91B460 for ; Wed, 3 Oct 2018 22:10:36 +0200 (CEST) In-Reply-To: <20180925150340.25378-4-jackmin@mellanox.com> Content-Language: en-US Content-ID: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Sep 25, 2018 at 11:03:40PM +0800, Xiaoyu Min wrote: > Offload following modify MAC address actions to E-Switch > via TC-Flower driver >=20 > - RTE_FLOW_ACTION_TYPE_SET_MAC_SRC > - RTE_FLOW_ACTION_TYPE_SET_MAC_DST >=20 > The corresponding rte_flow_item_eth must be present in > rte_flow pattern >=20 > Only support modify outer layer MAC address >=20 > Signed-off-by: Xiaoyu Min > --- Same comments as before. Thanks, Yongseok > drivers/net/mlx5/mlx5_flow.h | 2 ++ > drivers/net/mlx5/mlx5_flow_tcf.c | 62 +++++++++++++++++++++++++++++++- > 2 files changed, 63 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h > index 5237e31dd..76c4e8398 100644 > --- a/drivers/net/mlx5/mlx5_flow.h > +++ b/drivers/net/mlx5/mlx5_flow.h > @@ -95,6 +95,8 @@ > #define MLX5_ACTION_SET_TP_DST (1u << 16) > #define MLX5_ACTION_SET_TTL (1u << 17) > #define MLX5_ACTION_DEC_TTL (1u << 18) > +#define MLX5_ACTION_SET_MAC_SRC (1u << 19) > +#define MLX5_ACTION_SET_MAC_DST (1u << 20) > =20 > /* possible L3 layers protocols filtering. */ > #define MLX5_IP_PROTOCOL_TCP 6 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index af88c4a0d..cb60c3e05 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -303,7 +303,9 @@ struct flow_tcf_ptoi { > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TP_SRC || \ > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TP_DST || \ > (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_TTL || \ > - (act) =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TTL) ? \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_DEC_TTL || \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_MAC_SRC || \ > + (act) =3D=3D RTE_FLOW_ACTION_TYPE_SET_MAC_DST) ? \ > 1 : 0; }) > #define MAX_PEDIT_KEYS (128) > #define SZ_PEDIT_KEY_VAL (4) > @@ -327,6 +329,33 @@ flow_tcf_calc_pedit_keys(const uint64_t size) > return keys; > } > =20 > +static void > +flow_tcf_pedit_key_set_mac(const struct rte_flow_action *actions, > + struct pedit_parser *p_parser) > +{ > + int idx =3D p_parser->sel.nkeys; > + uint32_t off =3D > + actions->type =3D=3D RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ? 6 : 0; > + const struct rte_flow_action_set_mac *conf =3D > + (const struct rte_flow_action_set_mac *)actions->conf; > + > + p_parser->keys[idx].off =3D off; > + p_parser->keys[idx].mask =3D ~UINT32_MAX; > + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_ETH; > + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_SET; > + memcpy(&p_parser->keys[idx].val, > + conf->mac_addr, SZ_PEDIT_KEY_VAL); > + idx++; > + p_parser->keys[idx].off =3D off + SZ_PEDIT_KEY_VAL; > + p_parser->keys[idx].mask =3D 0xFFFF0000; > + p_parser->keys_ex[idx].htype =3D TCA_PEDIT_KEY_EX_HDR_TYPE_ETH; > + p_parser->keys_ex[idx].cmd =3D TCA_PEDIT_KEY_EX_CMD_SET; > + memcpy(&p_parser->keys[idx].val, > + conf->mac_addr + SZ_PEDIT_KEY_VAL, > + ETHER_ADDR_LEN - SZ_PEDIT_KEY_VAL); > + p_parser->sel.nkeys =3D (++idx); > +} > + > static void > flow_tcf_pedit_key_set_dec_ttl(const struct rte_flow_action *actions, > struct pedit_parser *p_parser, > @@ -447,6 +476,10 @@ flow_tcf_create_pedit_mnl_msg(struct nlmsghdr *nl, > flow_tcf_pedit_key_set_dec_ttl(*actions, > &p_parser, item_flags); > break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > + flow_tcf_pedit_key_set_mac(*actions, &p_parser); > + break; > default: > goto pedit_mnl_msg_done; > } > @@ -535,6 +568,14 @@ flow_tcf_get_pedit_actions_size(const struct rte_flo= w_action **actions, > keys +=3D flow_tcf_calc_pedit_keys(TTL_LEN); > flags |=3D MLX5_ACTION_DEC_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + keys +=3D flow_tcf_calc_pedit_keys(ETHER_ADDR_LEN); > + flags |=3D MLX5_ACTION_SET_MAC_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > + keys +=3D flow_tcf_calc_pedit_keys(ETHER_ADDR_LEN); > + flags |=3D MLX5_ACTION_SET_MAC_DST; > + break; > default: > goto get_pedit_action_size_done; > } > @@ -1041,6 +1082,12 @@ flow_tcf_validate(struct rte_eth_dev *dev, > case RTE_FLOW_ACTION_TYPE_DEC_TTL: > action_flags |=3D MLX5_ACTION_DEC_TTL; > break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + action_flags |=3D MLX5_ACTION_SET_MAC_SRC; > + break; > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > + action_flags |=3D MLX5_ACTION_SET_MAC_DST; > + break; > default: > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_ACTION, > @@ -1093,6 +1140,15 @@ flow_tcf_validate(struct rte_eth_dev *dev, > actions, > "no IP found in pattern"); > } > + if (action_flags & > + (MLX5_ACTION_SET_MAC_SRC | MLX5_ACTION_SET_MAC_DST)) { > + if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L2)) > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_ACTION, > + actions, > + "no ethernet found in" > + " pattern"); > + } > return 0; > } > =20 > @@ -1244,6 +1300,8 @@ flow_tcf_get_actions_and_size(const struct rte_flow= _action actions[], > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > case RTE_FLOW_ACTION_TYPE_SET_TTL: > case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > size +=3D flow_tcf_get_pedit_actions_size(&actions, > &flags); > break; > @@ -1788,6 +1846,8 @@ flow_tcf_translate(struct rte_eth_dev *dev, struct = mlx5_flow *dev_flow, > case RTE_FLOW_ACTION_TYPE_SET_TP_DST: > case RTE_FLOW_ACTION_TYPE_SET_TTL: > case RTE_FLOW_ACTION_TYPE_DEC_TTL: > + case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC: > + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: > na_act_index =3D > mnl_attr_nest_start(nlh, na_act_index_cur++); > flow_tcf_create_pedit_mnl_msg(nlh, > --=20 > 2.17.1 >=20