DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: Jack Min <jackmin@mellanox.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/mlx5: rewrite MAC address by E-Switch
Date: Thu, 11 Oct 2018 05:51:58 +0000	[thread overview]
Message-ID: <20181011055150.GD27741@mtidpdk.mti.labs.mlnx> (raw)
In-Reply-To: <20181010131108.24167-4-jackmin@mellanox.com>

On Wed, Oct 10, 2018 at 06:11:45AM -0700, Jack Min wrote:
> Offload following modify MAC address actions to E-Switch
> via TC-Flower driver
> 
> - RTE_FLOW_ACTION_TYPE_SET_MAC_SRC
> - RTE_FLOW_ACTION_TYPE_SET_MAC_DST
> 
> The corresponding rte_flow_item_eth must be present in
> rte_flow pattern
> 
> Only support modify outer layer MAC address
> 
> The example testpmd command is:
> 
>     flow create 0 transfer ingress
>          pattern eth / ipv4 / udp dst is 7000 / end
>          actions set_mac_dst mac_addr dd:00:aa:11:bb:33 /
>          set_mac_src mac_addr bb:00:cc:11:aa:22 /
> 	 port_id id 1 / end
> 
> Signed-off-by: Xiaoyu Min <jackmin@mellanox.com>
> ---
Acked-by: Yongseok Koh <yskoh@mellanox.com>

But you'll also need to rebase it on your other patchsets.

Thanks

>  drivers/net/mlx5/mlx5_flow.h     |  2 +
>  drivers/net/mlx5/mlx5_flow_tcf.c | 71 +++++++++++++++++++++++++++++++-
>  2 files changed, 72 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index 0ad8c12ea..22e648b36 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -86,6 +86,8 @@
>  #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16)
>  #define MLX5_FLOW_ACTION_SET_TTL (1u << 17)
>  #define MLX5_FLOW_ACTION_DEC_TTL (1u << 18)
> +#define MLX5_FLOW_ACTION_SET_MAC_SRC (1u << 19)
> +#define MLX5_FLOW_ACTION_SET_MAC_DST (1u << 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 af8a68529..c10fdd3fb 100644
> --- a/drivers/net/mlx5/mlx5_flow_tcf.c
> +++ b/drivers/net/mlx5/mlx5_flow_tcf.c
> @@ -305,7 +305,9 @@ struct flow_tcf_ptoi {
>  				MLX5_FLOW_ACTION_SET_TP_SRC   | \
>  				MLX5_FLOW_ACTION_SET_TP_DST   | \
>  				MLX5_FLOW_ACTION_SET_TTL      | \
> -				MLX5_FLOW_ACTION_DEC_TTL)
> +				MLX5_FLOW_ACTION_DEC_TTL      | \
> +				MLX5_FLOW_ACTION_SET_MAC_SRC  | \
> +				MLX5_FLOW_ACTION_SET_MAC_DST)
>  
>  #define MLX5_TCF_CONFIG_ACTIONS (MLX5_FLOW_ACTION_PORT_ID | \
>  				 MLX5_FLOW_ACTION_OF_PUSH_VLAN | \
> @@ -345,6 +347,42 @@ flow_tcf_calc_pedit_keys(const uint64_t size)
>  	return keys;
>  }
>  
> +/**
> + * Set pedit key of MAC address
> + *
> + * @param[in] actions
> + *   pointer to action specification
> + * @param[in,out] p_parser
> + *   pointer to pedit_parser
> + */
> +static void
> +flow_tcf_pedit_key_set_mac(const struct rte_flow_action *actions,
> +			   struct pedit_parser *p_parser)
> +{
> +	int idx = p_parser->sel.nkeys;
> +	uint32_t off = actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ?
> +					offsetof(struct ether_hdr, s_addr) :
> +					offsetof(struct ether_hdr, d_addr);
> +	const struct rte_flow_action_set_mac *conf =
> +		(const struct rte_flow_action_set_mac *)actions->conf;
> +
> +	p_parser->keys[idx].off = off;
> +	p_parser->keys[idx].mask = ~UINT32_MAX;
> +	p_parser->keys_ex[idx].htype = TCA_PEDIT_KEY_EX_HDR_TYPE_ETH;
> +	p_parser->keys_ex[idx].cmd = 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 = off + SZ_PEDIT_KEY_VAL;
> +	p_parser->keys[idx].mask = 0xFFFF0000;
> +	p_parser->keys_ex[idx].htype = TCA_PEDIT_KEY_EX_HDR_TYPE_ETH;
> +	p_parser->keys_ex[idx].cmd = 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 = (++idx);
> +}
> +
>  /**
>   * Set pedit key of decrease/set ttl
>   *
> @@ -529,6 +567,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;
>  		}
> @@ -617,6 +659,14 @@ flow_tcf_get_pedit_actions_size(const struct rte_flow_action **actions,
>  			keys += flow_tcf_calc_pedit_keys(TTL_LEN);
>  			flags |= MLX5_FLOW_ACTION_DEC_TTL;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
> +			keys += flow_tcf_calc_pedit_keys(ETHER_ADDR_LEN);
> +			flags |= MLX5_FLOW_ACTION_SET_MAC_SRC;
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
> +			keys += flow_tcf_calc_pedit_keys(ETHER_ADDR_LEN);
> +			flags |= MLX5_FLOW_ACTION_SET_MAC_DST;
> +			break;
>  		default:
>  			goto get_pedit_action_size_done;
>  		}
> @@ -1141,6 +1191,12 @@ flow_tcf_validate(struct rte_eth_dev *dev,
>  		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
>  			current_action_flag = MLX5_FLOW_ACTION_DEC_TTL;
>  			break;
> +		case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
> +			current_action_flag = MLX5_FLOW_ACTION_SET_MAC_SRC;
> +			break;
> +		case RTE_FLOW_ACTION_TYPE_SET_MAC_DST:
> +			current_action_flag = MLX5_FLOW_ACTION_SET_MAC_DST;
> +			break;
>  		default:
>  			return rte_flow_error_set(error, ENOTSUP,
>  						  RTE_FLOW_ERROR_TYPE_ACTION,
> @@ -1245,6 +1301,15 @@ flow_tcf_validate(struct rte_eth_dev *dev,
>  						  actions,
>  						  "no IP found in pattern");
>  	}
> +	if (action_flags &
> +	    (MLX5_FLOW_ACTION_SET_MAC_SRC | MLX5_FLOW_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;
>  }
>  
> @@ -1396,6 +1461,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 += flow_tcf_get_pedit_actions_size(&actions,
>  								&flags);
>  			break;
> @@ -1942,6 +2009,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 =
>  				mnl_attr_nest_start(nlh, na_act_index_cur++);
>  			flow_tcf_create_pedit_mnl_msg(nlh,
> -- 
> 2.17.1
> 

  reply	other threads:[~2018-10-11  5:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 15:03 [dpdk-dev] [PATCH 0/3] ethdev: add generic MAC address rewrite actions Xiaoyu Min
2018-09-25 15:03 ` [dpdk-dev] [PATCH 1/3] " Xiaoyu Min
2018-10-03 20:08   ` Yongseok Koh
2018-10-08  9:31   ` Andrew Rybchenko
2018-09-25 15:03 ` [dpdk-dev] [PATCH 2/3] app/testpmd: add commands of modify MAC address Xiaoyu Min
2018-10-03 20:09   ` Yongseok Koh
2018-09-25 15:03 ` [dpdk-dev] [PATCH 3/3] net/mlx5: eswitch-modify MAC address actions Xiaoyu Min
2018-10-03 20:10   ` Yongseok Koh
2018-10-05 12:54 ` [dpdk-dev] [PATCH 0/3] ethdev: add generic MAC address rewrite actions Ferruh Yigit
2018-10-08  2:32   ` Xiaoyu Min
2018-10-10 13:11 ` [dpdk-dev] [PATCH v2 " Jack Min
2018-10-10 13:11   ` [dpdk-dev] [PATCH v2 1/3] " Jack Min
2018-10-10 13:11   ` [dpdk-dev] [PATCH v2 2/3] app/testpmd: add commands of modify MAC address Jack Min
2018-10-10 13:11   ` [dpdk-dev] [PATCH v2 3/3] net/mlx5: rewrite MAC address by E-Switch Jack Min
2018-10-11  5:51     ` Yongseok Koh [this message]
2018-10-11 13:31   ` [dpdk-dev] [PATCH v3 0/3] ethdev: add generic MAC address rewrite actions Jack Min
2018-10-11 13:31     ` [dpdk-dev] [PATCH v3 1/3] " Jack Min
2018-10-11 13:31     ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: add commands of modify MAC address Jack Min
2018-10-11 13:31     ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: rewrite MAC address by E-Switch Jack Min
2018-10-16  9:11     ` [dpdk-dev] [PATCH v3 0/3] ethdev: add generic MAC address rewrite actions Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181011055150.GD27741@mtidpdk.mti.labs.mlnx \
    --to=yskoh@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=jackmin@mellanox.com \
    --cc=shahafs@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).