Skip to contentSkip to conversation

ice: add profile conflict check for AVF FDIR

PATCH Superseded Junfeng Guo 4 participants 9 messages Mar 9, 2023 – Mar 14, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: add profile conflict check for AVF FDIR

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +71 -0
index e6ef6b303222..1431789c194e 100644
@@ -541,6 +541,71 @@ static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)
 	}
 }
 
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+						to_fltr_conf_from_desc(desc);
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;
+
+		/* No need to compare two rules with different tunnel type */
+		if (existing_conf->ttype != conf->ttype)
+			continue;
+
+		/* No need to compare two rules with same protocol */
+		if (flow_type_a == flow_type_b)
+			continue;
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_SCTP)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_SCTP)
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +742,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr,
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf->vf_id);
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);
 	if (ret) {
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw
Quoted 5 lines · Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}
Quoted 7 lines

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

What about flow conflict when rule is added from host perspective (by ethtool)? Do we also need to check for conflict? Maybe it is worth create common code for this case.

Quoted 17 lines
Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +2 -0
index e6ef6b303222..1431789c194e 100644
@@ -541,6 +541,71 @@ static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)
 	}
 }
 
+/**
+ * ice_vc_fdir_has_prof_conflict

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 555

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)

It isn't aligned.

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 566

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +11 -0
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+						to_fltr_conf_from_desc(desc);
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;

I think You should folow RCT variable declaration here, and remove empty line.

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 574

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +8 -0
+
+		/* No need to compare two rules with different tunnel type */
+		if (existing_conf->ttype != conf->ttype)
+			continue;
+
+		/* No need to compare two rules with same protocol */
+		if (flow_type_a == flow_type_b)
+			continue;

This two ifs can be combined into one.

Quoted 57 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +40 -0
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_SCTP)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_SCTP)
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +742,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr,
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf->vf_id);
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);
 	if (ret) {
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw

Thanks for the review! Comments inline.

Quoted 42 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Thursday, March 9, 2023 22:02
To: Guo, Junfeng <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net] ice: add profile conflict check for AVF FDIR

Quoted 5 lines · Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}
Quoted 7 lines

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

What about flow conflict when rule is added from host perspective (by ethtool)? Do we also need to check for conflict? Maybe it is worth create common code for this case.

Review

Quoted 8 lines
Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct

Quoted 4 lines

index e6ef6b303222..1431789c194e 100644

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
@@ -541,6 +541,71 @@ static void ice_vc_fdir_rem_prof_all(struct

ice_vf *vf)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
 	}
 }
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 555

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +12 -0
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)

It isn't aligned.

I think here is just the display issue, the "+" at the beginning will occupy a character place. Once applied, it will show correctly.

Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 564

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+
	to_fltr_conf_from_desc(desc);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 566

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +5 -0
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;

I think You should folow RCT variable declaration here, and remove empty
line.

Thanks for the advice!

Do you mean update the code order like this?

	{
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a = &existing_conf->input;
	struct ice_fdir_fltr *b = &conf->input;

	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Or like this?
	{
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

	a = &existing_conf->input;
	b = &conf->input;
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 568

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +2 -0
+
+		/* No need to compare two rules with different tunnel

type */

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 574

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+		if (existing_conf->ttype != conf->ttype)
+			continue;
+
+		/* No need to compare two rules with same protocol */
+		if (flow_type_a == flow_type_b)
+			continue;

This two ifs can be combined into one.

Sure, it could be updated in the coming version. Thanks!

Quoted 64 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 585

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 586

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 597

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 598

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +742,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf,

struct virtchnl_fdir_add *fltr,

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf-
 vf_id);
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);

if (ret) {
--
2.25.1

Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw
Quoted 58 lines · Junfeng

Thanks for the review! Comments inline.

Quoted 42 lines

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Thursday, March 9, 2023 22:02
To: Guo, Junfeng <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net] ice: add profile conflict check for AVF FDIR

Quoted 5 lines · Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}
Quoted 7 lines

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

What about flow conflict when rule is added from host perspective (by ethtool)? Do we also need to check for conflict? Maybe it is worth create common code for this case.

Review

Quoted 8 lines
Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct

Quoted 4 lines

index e6ef6b303222..1431789c194e 100644

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
@@ -541,6 +541,71 @@ static void ice_vc_fdir_rem_prof_all(struct

ice_vf *vf)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
 	}
 }
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 555

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +12 -0
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)

It isn't aligned.

Quoted 3 lines

I think here is just the display issue, the "+" at the beginning will occupy a character place. Once applied, it will show correctly.

Oh, sure, sorry for pointing it.

Quoted 17 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 564

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+
	to_fltr_conf_from_desc(desc);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 566

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +5 -0
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;

I think You should folow RCT variable declaration here, and remove empty
line.

Quoted 5 lines

Thanks for the advice!

Do you mean update the code order like this?

	{

To follow RCT:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a, flow_type_b; struct ice_fdir_fltr *b = &conf->input;

Quoted 7 lines
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Or like this?
	{
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

This is also fine

Also fine will be:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a = a->flow_type; enum ice_fltr_ptype flow_type_b = b->flow_type; struct ice_fdir_fltr *b = &conf->input;

And it's look the best in my opinion, but it is only cosmetic.

Quoted 85 lines
	a = &existing_conf->input;
	b = &conf->input;
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 568

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +2 -0
+
+		/* No need to compare two rules with different tunnel

type */

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 574

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+		if (existing_conf->ttype != conf->ttype)
+			continue;
+
+		/* No need to compare two rules with same protocol */
+		if (flow_type_a == flow_type_b)
+			continue;

This two ifs can be combined into one.

Sure, it could be updated in the coming version. Thanks!

Quoted 64 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 585

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 586

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 597

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 598

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +742,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf,

struct virtchnl_fdir_add *fltr,

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf-
 vf_id);
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);

if (ret) {
--
2.25.1

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

maintainer
#4 lore raw
Quoted 1 line · Michal Swiatkowski

On Fri, Mar 10, 2023 at 05:16:22AM +0000, Guo, Junfeng wrote:

[...]

Quoted 30 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line

+

	to_fltr_conf_from_desc(desc);

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 566

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +5 -0
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;

I think You should folow RCT variable declaration here, and remove empty
line.

Quoted 5 lines

Thanks for the advice!

Do you mean update the code order like this?

	{

To follow RCT:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a, flow_type_b; struct ice_fdir_fltr *b = &conf->input;

Quoted 7 lines
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Or like this?
	{
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

This is also fine

Quoted 7 lines

Also fine will be:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a = a->flow_type; enum ice_fltr_ptype flow_type_b = b->flow_type; struct ice_fdir_fltr *b = &conf->input;

And it's look the best in my opinion, but it is only cosmetic.

Looks like flow type b has a dependency on fltr b so I don't think this will work.

Either of the suggestions previously mentioned should work:

	struct ice_fdir_fltr *a = &existing_conf->input;
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *b = &conf->input;

	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;

or:

	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

	a = &existing_conf->input;
	b = &conf->input;
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw
Quoted 67 lines

-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Saturday, March 11, 2023 02:03
To: Michal Swiatkowski <[email protected]>; Guo, Junfeng <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net] ice: add profile conflict check for AVF FDIR

Quoted 1 line · Michal Swiatkowski

On Fri, Mar 10, 2023 at 05:16:22AM +0000, Guo, Junfeng wrote:

[...]

Quoted 30 lines
Quoted 11 lines
Quoted 10 lines
Quoted 1 line

+

	to_fltr_conf_from_desc(desc);

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 566

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +5 -0
+		struct ice_fdir_fltr *a = &existing_conf->input;
+		struct ice_fdir_fltr *b = &conf->input;
+
+		enum ice_fltr_ptype flow_type_a = a->flow_type;
+		enum ice_fltr_ptype flow_type_b = b->flow_type;

I think You should folow RCT variable declaration here, and remove empty
line.

Quoted 5 lines

Thanks for the advice!

Do you mean update the code order like this?

	{

To follow RCT:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a, flow_type_b; struct ice_fdir_fltr *b = &conf->input;

Quoted 7 lines
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;
	}
Or like this?
	{
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

This is also fine

Quoted 7 lines

Also fine will be:
struct ice_fdir_fltr *a = &existing_conf->input; enum ice_fltr_ptype flow_type_a = a->flow_type; enum ice_fltr_ptype flow_type_b = b->flow_type; struct ice_fdir_fltr *b = &conf->input;

And it's look the best in my opinion, but it is only cosmetic.

Looks like flow type b has a dependency on fltr b so I don't think this will work.

Either of the suggestions previously mentioned should work:

	struct ice_fdir_fltr *a = &existing_conf->input;
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *b = &conf->input;

	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;

or:

Quoted 7 lines
	enum ice_fltr_ptype flow_type_a, flow_type_b;
	struct ice_fdir_fltr *a, *b;

	a = &existing_conf->input;
	b = &conf->input;
	flow_type_a = a->flow_type;
	flow_type_b = b->flow_type;

LGTM, thank you all for the careful review!
Will update this in the coming version patch.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#6 lore raw

PATCH v2 1/1 ice: add profile conflict check for AVF FDIR

In reply to Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +73 -0
index e6ef6b303222..06296ffc3608 100644
@@ -541,6 +541,73 @@ static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)
 	}
 }
 
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+						to_fltr_conf_from_desc(desc);
+		enum ice_fltr_ptype flow_type_a, flow_type_b;
+		struct ice_fdir_fltr *a, *b;
+
+		a = &existing_conf->input;
+		b = &conf->input;
+		flow_type_a = a->flow_type;
+		flow_type_b = b->flow_type;
+
+		/**
+		 * No need to compare two rules with different tunnel types or
+		 * with the same protocol type
+		 */
+		if (existing_conf->ttype != conf->ttype ||
+		    flow_type_a == flow_type_b)
+			continue;
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_SCTP)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_SCTP)
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +744,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr,
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf->vf_id);
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);
 	if (ret) {
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#7 lore raw
Quoted 45 lines · Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +18 -0
index e6ef6b303222..06296ffc3608 100644
@@ -541,6 +541,73 @@ static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)
 	}
 }
 
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+						to_fltr_conf_from_desc(desc);

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 571

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+		enum ice_fltr_ptype flow_type_a, flow_type_b;
+		struct ice_fdir_fltr *a, *b;
+
+		a = &existing_conf->input;
+		b = &conf->input;
+		flow_type_a = a->flow_type;
+		flow_type_b = b->flow_type;
+
+		/**
+		 * No need to compare two rules with different tunnel types or

"/**" is special magic for declaring documentation in kernel and doxygen. Just use:

/* multi-line
* comment
*/

which is netdev style.

Quoted 43 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +39 -0
+		 * with the same protocol type
+		 */
+		if (existing_conf->ttype != conf->ttype ||
+		    flow_type_a == flow_type_b)
+			continue;
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV4_SCTP)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_OTHER)
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_UDP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_TCP ||
+			    flow_type_b == ICE_FLTR_PTYPE_NONF_IPV6_SCTP)
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr, · line 749

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +3 -0
@@ -677,6 +744,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr,
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf->vf_id);

This is just a nit, but generally messages to the log should always contain full words and not abbreviations.

"Found flow profile conflict for VF %d\n"

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr, · line 755

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +3 -0
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);
 	if (ret) {

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#8 lore raw
Quoted 71 lines

-----Original Message-----
From: Brandeburg, Jesse <[email protected]>
Sent: Monday, March 13, 2023 23:51
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net v2] ice: add profile conflict check for AVF FDIR

Quoted 13 lines · Junfeng Guo

Add profile conflict check while adding some FDIR rules to aviod unexpected flow behavior, rules may have conflict including:

        IPv4 <---> {IPv4_UDP, IPv4_TCP, IPv4_SCTP}
        IPv6 <---> {IPv6_UDP, IPv6_TCP, IPv6_SCTP}

For example, when we create an FDIR rule for IPv4, this rule will work on packets including IPv4, IPv4_UDP, IPv4_TCP and IPv4_SCTP. But if we then create an FDIR rule for IPv4_UDP and then destroy it, the first FDIR rule for IPv4 cannot work on pkt IPv4_UDP then.

To prevent this unexpected behavior, we add restriction in software when creating FDIR rules by adding necessary profile conflict check.

Review

Quoted 7 lines
Fixes 1f7ea1cd6a37 ("ice: Enable FDIR Configure for AVF")
---
 .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct

Quoted 4 lines

index e6ef6b303222..06296ffc3608 100644

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0 -0
@@ -541,6 +541,73 @@ static void ice_vc_fdir_rem_prof_all(struct

ice_vf *vf)

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +8 -0
 	}
 }
 
+/**
+ * ice_vc_fdir_has_prof_conflict
+ * @vf: pointer to the VF structure
+ * @conf: FDIR configuration for each filter
+ *
+ * Check if @conf has conflicting profile with existing profiles
+ *
+ * Return: true on success, and false on error.

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf) · line 564

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+ */
+static bool
+ice_vc_fdir_has_prof_conflict(struct ice_vf *vf,
+			      struct virtchnl_fdir_fltr_conf *conf)
+{
+	struct ice_fdir_fltr *desc;
+
+	list_for_each_entry(desc, &vf->fdir.fdir_rule_list, fltr_node) {
+		struct virtchnl_fdir_fltr_conf *existing_conf =
+
	to_fltr_conf_from_desc(desc);

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+		enum ice_fltr_ptype flow_type_a, flow_type_b;
+		struct ice_fdir_fltr *a, *b;
+
+		a = &existing_conf->input;
+		b = &conf->input;
+		flow_type_a = a->flow_type;
+		flow_type_b = b->flow_type;
+
+		/**
+		 * No need to compare two rules with different tunnel

types or

Quoted 8 lines

"/**" is special magic for declaring documentation in kernel and doxygen. Just use:

/* multi-line
* comment
*/

which is netdev style.

Sure, will follow this style. Thanks for the reminding!

Quoted 64 lines

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +11 -0
+		 * with the same protocol type
+		 */
+		if (existing_conf->ttype != conf->ttype ||
+		    flow_type_a == flow_type_b)
+			continue;
+
+		switch (flow_type_a) {
+		case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 587

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 588

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV4_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +6 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_OTHER)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct ice_vf *vf)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +4 -0
+				return true;
+			break;
+		case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+			if (flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_UDP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 599

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_TCP ||

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c static void ice_vc_fdir_rem_prof_all(struct · line 600

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
+			    flow_type_b ==

ICE_FLTR_PTYPE_NONF_IPV6_SCTP)

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +10 -0
+				return true;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return false;
+}
+
 /**
  * ice_vc_fdir_write_flow_prof
  * @vf: pointer to the VF structure
@@ -677,6 +744,12 @@ ice_vc_fdir_config_input_set(struct ice_vf *vf,

struct virtchnl_fdir_add *fltr,

drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_config_input_set(struct ice_vf *vf, struct virtchnl_fdir_add *fltr,

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +3 -0
 	enum ice_fltr_ptype flow;
 	int ret;
 
+	ret = ice_vc_fdir_has_prof_conflict(vf, conf);
+	if (ret) {
+		dev_dbg(dev, "Found flow prof conflict for VF %d\n", vf-
 vf_id);

This is just a nit, but generally messages to the log should always contain full words and not abbreviations.

Quoted 1 line

"Found flow profile conflict for VF %d\n"

Will update this, thanks!

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +3 -0
+		return ret;
+	}
+
 	flow = input->flow_type;
 	ret = ice_vc_fdir_alloc_prof(vf, flow);

if (ret) {

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan