diff mbox series

[net-next] ice: VLAN untagged traffic support

Message ID 20230726105054.295220-1-wojciech.drewek@intel.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ice: VLAN untagged traffic support | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1342 this patch: 1342
netdev/cc_maintainers warning 6 maintainers not CCed: kuba@kernel.org jesse.brandeburg@intel.com davem@davemloft.net anthony.l.nguyen@intel.com pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 1365 this patch: 1365
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1365 this patch: 1365
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Wojciech Drewek July 26, 2023, 10:50 a.m. UTC
When driver recives SWITCHDEV_FDB_ADD_TO_DEVICE notification
with vid = 1, it means that we have to offload untagged traffic.
This is achieved by adding vlan metadata lookup.

Also remove unnecessary brackets in ice_eswitch_br_fdb_entry_create.

Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_eswitch_br.c | 9 +++++----
 drivers/net/ethernet/intel/ice/ice_eswitch_br.h | 9 ---------
 2 files changed, 5 insertions(+), 13 deletions(-)

Comments

Paul Menzel July 26, 2023, 11:40 a.m. UTC | #1
Dear Wojciech,


Thank you for your patch.

Could you use a statement as summary by using a verb (in imperative 
mood)? Maybe:

Support untagged VLAN traffic

Am 26.07.23 um 12:50 schrieb Wojciech Drewek:
> When driver recives SWITCHDEV_FDB_ADD_TO_DEVICE notification

receives

> with vid = 1, it means that we have to offload untagged traffic.
> This is achieved by adding vlan metadata lookup.
> 
> Also remove unnecessary brackets in ice_eswitch_br_fdb_entry_create.

For things starting with “Also” in the git commit message, that’s a good 
indicator for a separate commit. ;-)

> Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_eswitch_br.c | 9 +++++----
>   drivers/net/ethernet/intel/ice/ice_eswitch_br.h | 9 ---------
>   2 files changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> index 67bfd1f61cdd..05bee706b946 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> @@ -104,13 +104,15 @@ ice_eswitch_br_rule_delete(struct ice_hw *hw, struct ice_rule_query_data *rule)
>   static u16
>   ice_eswitch_br_get_lkups_cnt(u16 vid)
>   {
> -	return ice_eswitch_br_is_vid_valid(vid) ? 2 : 1;
> +	return vid == 0 ? 1 : 2;

Should some comment be added to the function to explain the behavior?

>   }
>   
>   static void
>   ice_eswitch_br_add_vlan_lkup(struct ice_adv_lkup_elem *list, u16 vid)
>   {
> -	if (ice_eswitch_br_is_vid_valid(vid)) {
> +	if (vid == 1) {
> +		ice_rule_add_vlan_metadata(&list[1]);
> +	} else if (vid > 1) {

Why is vid == 1 treated differently from the others?


Kind regards,

Paul


>   		list[1].type = ICE_VLAN_OFOS;
>   		list[1].h_u.vlan_hdr.vlan = cpu_to_be16(vid & VLAN_VID_MASK);
>   		list[1].m_u.vlan_hdr.vlan = cpu_to_be16(0xFFFF);
> @@ -400,11 +402,10 @@ ice_eswitch_br_fdb_entry_create(struct net_device *netdev,
>   	unsigned long event;
>   	int err;
>   
> -	/* untagged filtering is not yet supported */
>   	if (!(bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) && vid)
>   		return;
>   
> -	if ((bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING)) {
> +	if (bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) {
>   		vlan = ice_esw_br_port_vlan_lookup(bridge, br_port->vsi_idx,
>   						   vid);
>   		if (IS_ERR(vlan)) {
> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> index 85a8fadb2928..cf7b0e5acfcb 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> @@ -103,15 +103,6 @@ struct ice_esw_br_vlan {
>   		     struct ice_esw_br_fdb_work, \
>   		     work)
>   
> -static inline bool ice_eswitch_br_is_vid_valid(u16 vid)
> -{
> -	/* In trunk VLAN mode, for untagged traffic the bridge sends requests
> -	 * to offload VLAN 1 with pvid and untagged flags set. Since these
> -	 * flags are not supported, add a MAC filter instead.
> -	 */
> -	return vid > 1;
> -}
> -
>   void
>   ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
>   int
Wojciech Drewek July 27, 2023, 9:18 a.m. UTC | #2
Hi Paul,

Thanks for review

> -----Original Message-----
> From: Paul Menzel <pmenzel@molgen.mpg.de>
> Sent: środa, 26 lipca 2023 13:41
> To: Drewek, Wojciech <wojciech.drewek@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org
> Subject: Re: [Intel-wired-lan] [PATCH net-next] ice: VLAN untagged traffic support
> 
> Dear Wojciech,
> 
> 
> Thank you for your patch.
> 
> Could you use a statement as summary by using a verb (in imperative
> mood)? Maybe:
> 
> Support untagged VLAN traffic

sure

> 
> Am 26.07.23 um 12:50 schrieb Wojciech Drewek:
> > When driver recives SWITCHDEV_FDB_ADD_TO_DEVICE notification
> 
> receives
> 
> > with vid = 1, it means that we have to offload untagged traffic.
> > This is achieved by adding vlan metadata lookup.
> >
> > Also remove unnecessary brackets in ice_eswitch_br_fdb_entry_create.
> 
> For things starting with “Also” in the git commit message, that’s a good
> indicator for a separate commit. ;-)

ok

> 
> > Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
> > ---
> >   drivers/net/ethernet/intel/ice/ice_eswitch_br.c | 9 +++++----
> >   drivers/net/ethernet/intel/ice/ice_eswitch_br.h | 9 ---------
> >   2 files changed, 5 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> > index 67bfd1f61cdd..05bee706b946 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> > @@ -104,13 +104,15 @@ ice_eswitch_br_rule_delete(struct ice_hw *hw, struct ice_rule_query_data *rule)
> >   static u16
> >   ice_eswitch_br_get_lkups_cnt(u16 vid)
> >   {
> > -	return ice_eswitch_br_is_vid_valid(vid) ? 2 : 1;
> > +	return vid == 0 ? 1 : 2;
> 
> Should some comment be added to the function to explain the behavior?

Will do

> 
> >   }
> >
> >   static void
> >   ice_eswitch_br_add_vlan_lkup(struct ice_adv_lkup_elem *list, u16 vid)
> >   {
> > -	if (ice_eswitch_br_is_vid_valid(vid)) {
> > +	if (vid == 1) {
> > +		ice_rule_add_vlan_metadata(&list[1]);
> > +	} else if (vid > 1) {
> 
> Why is vid == 1 treated differently from the others?

With vid ==1 we want to match on MAC but without vlan tags. To achieve this, we're
adding vlan metadata (matching on all vlan tags) but we do not add ICE_VLAN_OFOS
lookup type which gives us mac + not vlan matching criteria.

> 
> 
> Kind regards,
> 
> Paul
> 
> 
> >   		list[1].type = ICE_VLAN_OFOS;
> >   		list[1].h_u.vlan_hdr.vlan = cpu_to_be16(vid & VLAN_VID_MASK);
> >   		list[1].m_u.vlan_hdr.vlan = cpu_to_be16(0xFFFF);
> > @@ -400,11 +402,10 @@ ice_eswitch_br_fdb_entry_create(struct net_device *netdev,
> >   	unsigned long event;
> >   	int err;
> >
> > -	/* untagged filtering is not yet supported */
> >   	if (!(bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) && vid)
> >   		return;
> >
> > -	if ((bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING)) {
> > +	if (bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) {
> >   		vlan = ice_esw_br_port_vlan_lookup(bridge, br_port->vsi_idx,
> >   						   vid);
> >   		if (IS_ERR(vlan)) {
> > diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> > index 85a8fadb2928..cf7b0e5acfcb 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> > +++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> > @@ -103,15 +103,6 @@ struct ice_esw_br_vlan {
> >   		     struct ice_esw_br_fdb_work, \
> >   		     work)
> >
> > -static inline bool ice_eswitch_br_is_vid_valid(u16 vid)
> > -{
> > -	/* In trunk VLAN mode, for untagged traffic the bridge sends requests
> > -	 * to offload VLAN 1 with pvid and untagged flags set. Since these
> > -	 * flags are not supported, add a MAC filter instead.
> > -	 */
> > -	return vid > 1;
> > -}
> > -
> >   void
> >   ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
> >   int
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
index 67bfd1f61cdd..05bee706b946 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
@@ -104,13 +104,15 @@  ice_eswitch_br_rule_delete(struct ice_hw *hw, struct ice_rule_query_data *rule)
 static u16
 ice_eswitch_br_get_lkups_cnt(u16 vid)
 {
-	return ice_eswitch_br_is_vid_valid(vid) ? 2 : 1;
+	return vid == 0 ? 1 : 2;
 }
 
 static void
 ice_eswitch_br_add_vlan_lkup(struct ice_adv_lkup_elem *list, u16 vid)
 {
-	if (ice_eswitch_br_is_vid_valid(vid)) {
+	if (vid == 1) {
+		ice_rule_add_vlan_metadata(&list[1]);
+	} else if (vid > 1) {
 		list[1].type = ICE_VLAN_OFOS;
 		list[1].h_u.vlan_hdr.vlan = cpu_to_be16(vid & VLAN_VID_MASK);
 		list[1].m_u.vlan_hdr.vlan = cpu_to_be16(0xFFFF);
@@ -400,11 +402,10 @@  ice_eswitch_br_fdb_entry_create(struct net_device *netdev,
 	unsigned long event;
 	int err;
 
-	/* untagged filtering is not yet supported */
 	if (!(bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) && vid)
 		return;
 
-	if ((bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING)) {
+	if (bridge->flags & ICE_ESWITCH_BR_VLAN_FILTERING) {
 		vlan = ice_esw_br_port_vlan_lookup(bridge, br_port->vsi_idx,
 						   vid);
 		if (IS_ERR(vlan)) {
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
index 85a8fadb2928..cf7b0e5acfcb 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
@@ -103,15 +103,6 @@  struct ice_esw_br_vlan {
 		     struct ice_esw_br_fdb_work, \
 		     work)
 
-static inline bool ice_eswitch_br_is_vid_valid(u16 vid)
-{
-	/* In trunk VLAN mode, for untagged traffic the bridge sends requests
-	 * to offload VLAN 1 with pvid and untagged flags set. Since these
-	 * flags are not supported, add a MAC filter instead.
-	 */
-	return vid > 1;
-}
-
 void
 ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
 int