mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user()
A new tagging protocol implementation based on tag_8021q is on the horizon, and it appears that it also has to open-code the complicated logic of finding a source port based on a VLAN header. Create a single dsa_tag_8021q_find_user() and make sja1105 call it. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://patch.msgid.link/20240713211620.1125910-7-paweldembicki@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
		
							parent
							
								
									823e5cc141
								
							
						
					
					
						commit
						d124cf54df
					
				
					 3 changed files with 24 additions and 17 deletions
				
			
		| 
						 | 
					@ -468,8 +468,8 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(dsa_8021q_xmit);
 | 
					EXPORT_SYMBOL_GPL(dsa_8021q_xmit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit,
 | 
					static struct net_device *
 | 
				
			||||||
						   int vbid)
 | 
					dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, int vbid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct dsa_port *cpu_dp = conduit->dsa_ptr;
 | 
						struct dsa_port *cpu_dp = conduit->dsa_ptr;
 | 
				
			||||||
	struct dsa_switch_tree *dst = cpu_dp->dst;
 | 
						struct dsa_switch_tree *dst = cpu_dp->dst;
 | 
				
			||||||
| 
						 | 
					@ -495,7 +495,20 @@ struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid);
 | 
					
 | 
				
			||||||
 | 
					struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit,
 | 
				
			||||||
 | 
										   int source_port, int switch_id,
 | 
				
			||||||
 | 
										   int vid, int vbid)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/* Always prefer precise source port information, if available */
 | 
				
			||||||
 | 
						if (source_port != -1 && switch_id != -1)
 | 
				
			||||||
 | 
							return dsa_conduit_find_user(conduit, switch_id, source_port);
 | 
				
			||||||
 | 
						else if (vbid >= 1)
 | 
				
			||||||
 | 
							return dsa_tag_8021q_find_port_by_vbid(conduit, vbid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dsa_find_designated_bridge_port_by_vid(conduit, vid);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_user);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * dsa_8021q_rcv - Decode source information from tag_8021q header
 | 
					 * dsa_8021q_rcv - Decode source information from tag_8021q header
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,8 +16,9 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
 | 
				
			||||||
void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id,
 | 
					void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id,
 | 
				
			||||||
		   int *vbid, int *vid);
 | 
							   int *vbid, int *vid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit,
 | 
					struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit,
 | 
				
			||||||
						   int vbid);
 | 
										   int source_port, int switch_id,
 | 
				
			||||||
 | 
										   int vid, int vbid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds,
 | 
					int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds,
 | 
				
			||||||
				  struct dsa_notifier_tag_8021q_vlan_info *info);
 | 
									  struct dsa_notifier_tag_8021q_vlan_info *info);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -509,12 +509,8 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (source_port != -1 && switch_id != -1)
 | 
						skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id,
 | 
				
			||||||
		skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port);
 | 
										   vid, vbid);
 | 
				
			||||||
	else if (vbid >= 1)
 | 
					 | 
				
			||||||
		skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid);
 | 
					 | 
				
			||||||
	if (!skb->dev) {
 | 
						if (!skb->dev) {
 | 
				
			||||||
		netdev_warn(netdev, "Couldn't decode source port\n");
 | 
							netdev_warn(netdev, "Couldn't decode source port\n");
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
| 
						 | 
					@ -652,12 +648,9 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb,
 | 
				
			||||||
	if (likely(sja1105_skb_has_tag_8021q(skb)))
 | 
						if (likely(sja1105_skb_has_tag_8021q(skb)))
 | 
				
			||||||
		dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid);
 | 
							dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (source_port != -1 && switch_id != -1)
 | 
						skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id,
 | 
				
			||||||
		skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port);
 | 
										   vid, vbid);
 | 
				
			||||||
	else if (vbid >= 1)
 | 
					
 | 
				
			||||||
		skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid);
 | 
					 | 
				
			||||||
	if (!skb->dev) {
 | 
						if (!skb->dev) {
 | 
				
			||||||
		netdev_warn(netdev, "Couldn't decode source port\n");
 | 
							netdev_warn(netdev, "Couldn't decode source port\n");
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue