diff mbox series

[net-next,1/3] net/sched: add vlan push_eth and pop_eth action to the hardware IR

Message ID 20220309130256.1402040-2-roid@nvidia.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series flow_offload: add tc vlan push_eth and pop_eth actions | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1899 this patch: 1899
netdev/cc_maintainers warning 2 maintainers not CCed: xiyou.wangcong@gmail.com jiri@resnulli.us
netdev/build_clang success Errors and warnings before: 206 this patch: 206
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2052 this patch: 2052
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns WARNING: line length of 84 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Roi Dayan March 9, 2022, 1:02 p.m. UTC
From: Maor Dickman <maord@nvidia.com>

Add vlan push_eth and pop_eth action to the hardware intermediate
representation model which would subsequently allow it to be used
by drivers for offload.

Signed-off-by: Maor Dickman <maord@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
---
 include/net/flow_offload.h   |  4 ++++
 include/net/tc_act/tc_vlan.h | 14 ++++++++++++++
 net/sched/act_vlan.c         | 14 ++++++++++++++
 3 files changed, 32 insertions(+)

Comments

Jakub Kicinski March 15, 2022, 5:02 a.m. UTC | #1
Sorry for the late review.

On Wed, 9 Mar 2022 15:02:54 +0200 Roi Dayan wrote:
> @@ -211,6 +213,8 @@ struct flow_action_entry {
>  			__be16		proto;
>  			u8		prio;
>  		} vlan;
> +		unsigned char vlan_push_eth_dst[ETH_ALEN];
> +		unsigned char vlan_push_eth_src[ETH_ALEN];

Let's wrap these two in a struct, like all other members here, 
and add the customary comment indicating which action its for.

>  		struct {				/* FLOW_ACTION_MANGLE */
>  							/* FLOW_ACTION_ADD */
>  			enum flow_action_mangle_base htype;
> diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h
> index f94b8bc26f9e..8a3422c70f9f 100644
> --- a/include/net/tc_act/tc_vlan.h
> +++ b/include/net/tc_act/tc_vlan.h
> @@ -78,4 +78,18 @@ static inline u8 tcf_vlan_push_prio(const struct tc_action *a)
>  
>  	return tcfv_push_prio;
>  }
> +
> +static inline void tcf_vlan_push_dst(unsigned char *dest, const struct tc_action *a)
> +{
> +	rcu_read_lock();
> +	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_dst, ETH_ALEN);
> +	rcu_read_unlock();
> +}
> +
> +static inline void tcf_vlan_push_src(unsigned char *dest, const struct tc_action *a)
> +{
> +	rcu_read_lock();
> +	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_src, ETH_ALEN);
> +	rcu_read_unlock();
> +}

The use of these two helpers separately makes no sense, we can't push
half a header. It should be one helper populating both src and dst, IMO.
Roi Dayan March 15, 2022, 9:53 a.m. UTC | #2
On 2022-03-15 7:02 AM, Jakub Kicinski wrote:
> Sorry for the late review.
> 
> On Wed, 9 Mar 2022 15:02:54 +0200 Roi Dayan wrote:
>> @@ -211,6 +213,8 @@ struct flow_action_entry {
>>   			__be16		proto;
>>   			u8		prio;
>>   		} vlan;
>> +		unsigned char vlan_push_eth_dst[ETH_ALEN];
>> +		unsigned char vlan_push_eth_src[ETH_ALEN];
> 
> Let's wrap these two in a struct, like all other members here,
> and add the customary comment indicating which action its for.
> 

ok.

>>   		struct {				/* FLOW_ACTION_MANGLE */
>>   							/* FLOW_ACTION_ADD */
>>   			enum flow_action_mangle_base htype;
>> diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h
>> index f94b8bc26f9e..8a3422c70f9f 100644
>> --- a/include/net/tc_act/tc_vlan.h
>> +++ b/include/net/tc_act/tc_vlan.h
>> @@ -78,4 +78,18 @@ static inline u8 tcf_vlan_push_prio(const struct tc_action *a)
>>   
>>   	return tcfv_push_prio;
>>   }
>> +
>> +static inline void tcf_vlan_push_dst(unsigned char *dest, const struct tc_action *a)
>> +{
>> +	rcu_read_lock();
>> +	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_dst, ETH_ALEN);
>> +	rcu_read_unlock();
>> +}
>> +
>> +static inline void tcf_vlan_push_src(unsigned char *dest, const struct tc_action *a)
>> +{
>> +	rcu_read_lock();
>> +	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_src, ETH_ALEN);
>> +	rcu_read_unlock();
>> +}
> 
> The use of these two helpers separately makes no sense, we can't push
> half a header. It should be one helper populating both src and dst, IMO.

ok.
diff mbox series

Patch

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 92267d23083e..2bfa666842c5 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -150,6 +150,8 @@  enum flow_action_id {
 	FLOW_ACTION_PPPOE_PUSH,
 	FLOW_ACTION_JUMP,
 	FLOW_ACTION_PIPE,
+	FLOW_ACTION_VLAN_PUSH_ETH,
+	FLOW_ACTION_VLAN_POP_ETH,
 	NUM_FLOW_ACTIONS,
 };
 
@@ -211,6 +213,8 @@  struct flow_action_entry {
 			__be16		proto;
 			u8		prio;
 		} vlan;
+		unsigned char vlan_push_eth_dst[ETH_ALEN];
+		unsigned char vlan_push_eth_src[ETH_ALEN];
 		struct {				/* FLOW_ACTION_MANGLE */
 							/* FLOW_ACTION_ADD */
 			enum flow_action_mangle_base htype;
diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h
index f94b8bc26f9e..8a3422c70f9f 100644
--- a/include/net/tc_act/tc_vlan.h
+++ b/include/net/tc_act/tc_vlan.h
@@ -78,4 +78,18 @@  static inline u8 tcf_vlan_push_prio(const struct tc_action *a)
 
 	return tcfv_push_prio;
 }
+
+static inline void tcf_vlan_push_dst(unsigned char *dest, const struct tc_action *a)
+{
+	rcu_read_lock();
+	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_dst, ETH_ALEN);
+	rcu_read_unlock();
+}
+
+static inline void tcf_vlan_push_src(unsigned char *dest, const struct tc_action *a)
+{
+	rcu_read_lock();
+	memcpy(dest, rcu_dereference(to_vlan(a)->vlan_p)->tcfv_push_src, ETH_ALEN);
+	rcu_read_unlock();
+}
 #endif /* __NET_TC_VLAN_H */
diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
index 756e2dcde1cd..d27604204f17 100644
--- a/net/sched/act_vlan.c
+++ b/net/sched/act_vlan.c
@@ -390,6 +390,14 @@  static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data,
 			entry->vlan.proto = tcf_vlan_push_proto(act);
 			entry->vlan.prio = tcf_vlan_push_prio(act);
 			break;
+		case TCA_VLAN_ACT_POP_ETH:
+			entry->id = FLOW_ACTION_VLAN_POP_ETH;
+			break;
+		case TCA_VLAN_ACT_PUSH_ETH:
+			entry->id = FLOW_ACTION_VLAN_PUSH_ETH;
+			tcf_vlan_push_dst(entry->vlan_push_eth_dst, act);
+			tcf_vlan_push_src(entry->vlan_push_eth_src, act);
+			break;
 		default:
 			return -EOPNOTSUPP;
 		}
@@ -407,6 +415,12 @@  static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data,
 		case TCA_VLAN_ACT_MODIFY:
 			fl_action->id = FLOW_ACTION_VLAN_MANGLE;
 			break;
+		case TCA_VLAN_ACT_POP_ETH:
+			fl_action->id = FLOW_ACTION_VLAN_POP_ETH;
+			break;
+		case TCA_VLAN_ACT_PUSH_ETH:
+			fl_action->id = FLOW_ACTION_VLAN_PUSH_ETH;
+			break;
 		default:
 			return -EOPNOTSUPP;
 		}