[dpdk-dev] [PATCH v5 2/4] net/mlx5: tc flow to use the new infrastructure
Moti Haimovsky
motih at mellanox.com
Thu Oct 18 20:29:21 CEST 2018
modified TC-flow code to use the new infrastructure
introduced in "net/mlx5: refactor TC-flow infrastructure"
commit.
Signed-off-by: Moti Haimovsky <motih at mellanox.com>
---
v5:
* Initial version of this patch.
---
drivers/net/mlx5/mlx5_flow_tcf.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c
index 5ce2d5f..b890aa2 100644
--- a/drivers/net/mlx5/mlx5_flow_tcf.c
+++ b/drivers/net/mlx5/mlx5_flow_tcf.c
@@ -2116,8 +2116,8 @@ struct pedit_parser {
/**
* Send Netlink message with acknowledgment.
*
- * @param nl
- * Libmnl socket to use.
+ * @param ctx
+ * Flow context to use.
* @param nlh
* Message to send. This function always raises the NLM_F_ACK flag before
* sending.
@@ -2126,12 +2126,13 @@ struct pedit_parser {
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
-flow_tcf_nl_ack(struct mnl_socket *nl, struct nlmsghdr *nlh)
+flow_tcf_nl_ack(struct mlx5_flow_tcf_context *ctx, struct nlmsghdr *nlh)
{
alignas(struct nlmsghdr)
uint8_t ans[mnl_nlmsg_size(sizeof(struct nlmsgerr)) +
nlh->nlmsg_len - sizeof(*nlh)];
- uint32_t seq = random();
+ uint32_t seq = ctx->seq++;
+ struct mnl_socket *nl = ctx->nl;
int ret;
nlh->nlmsg_flags |= NLM_F_ACK;
@@ -2166,7 +2167,7 @@ struct pedit_parser {
struct rte_flow_error *error)
{
struct priv *priv = dev->data->dev_private;
- struct mnl_socket *nl = priv->tcf_context->nl;
+ struct mlx5_flow_tcf_context *ctx = priv->tcf_context;
struct mlx5_flow *dev_flow;
struct nlmsghdr *nlh;
@@ -2176,7 +2177,7 @@ struct pedit_parser {
nlh = dev_flow->tcf.nlh;
nlh->nlmsg_type = RTM_NEWTFILTER;
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;
- if (!flow_tcf_nl_ack(nl, nlh))
+ if (!flow_tcf_nl_ack(ctx, nlh))
return 0;
return rte_flow_error_set(error, rte_errno,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -2195,7 +2196,7 @@ struct pedit_parser {
flow_tcf_remove(struct rte_eth_dev *dev, struct rte_flow *flow)
{
struct priv *priv = dev->data->dev_private;
- struct mnl_socket *nl = priv->tcf_context->nl;
+ struct mlx5_flow_tcf_context *ctx = priv->tcf_context;
struct mlx5_flow *dev_flow;
struct nlmsghdr *nlh;
@@ -2209,7 +2210,7 @@ struct pedit_parser {
nlh = dev_flow->tcf.nlh;
nlh->nlmsg_type = RTM_DELTFILTER;
nlh->nlmsg_flags = NLM_F_REQUEST;
- flow_tcf_nl_ack(nl, nlh);
+ flow_tcf_nl_ack(ctx, nlh);
}
/**
@@ -2302,7 +2303,6 @@ struct pedit_parser {
{
struct nlmsghdr *nlh;
struct tcmsg *tcm;
- struct mnl_socket *nl = ctx->nl;
alignas(struct nlmsghdr)
uint8_t buf[mnl_nlmsg_size(sizeof(*tcm) + 128)];
@@ -2316,7 +2316,7 @@ struct pedit_parser {
tcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);
tcm->tcm_parent = TC_H_INGRESS;
/* Ignore errors when qdisc is already absent. */
- if (flow_tcf_nl_ack(nl, nlh) &&
+ if (flow_tcf_nl_ack(ctx, nlh) &&
rte_errno != EINVAL && rte_errno != ENOENT)
return rte_flow_error_set(error, rte_errno,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -2332,7 +2332,7 @@ struct pedit_parser {
tcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);
tcm->tcm_parent = TC_H_INGRESS;
mnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, "ingress");
- if (flow_tcf_nl_ack(nl, nlh))
+ if (flow_tcf_nl_ack(ctx, nlh))
return rte_flow_error_set(error, rte_errno,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"netlink: failed to create ingress"
@@ -2373,7 +2373,7 @@ struct mlx5_flow_tcf_context *
/**
* Destroy a libmnl context.
*
- * @param nl
+ * @param ctx
* Libmnl socket of the @p NETLINK_ROUTE kind.
*/
void
--
1.8.3.1
More information about the dev
mailing list