Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c34ca47 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'dsa-tagger-simplification'



Vivien Didelot says:

====================
net: dsa: tagger simplification

This series clarifies the hot path, removes the labels in tagging
implementations, and frees the original SKB in the xmit caller.

Changes in v3:
  - drop removal of usused rcv arguments because they will be used later
  - include the new ksz tagging implementation
  - add reviewers' tags

Changes in v2:
  - do not remove tagger function copies
  - document hot path requirements
  - make netdev_uses_dsa simpler
  - add reviewers' tags
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0266f797 fe47d563
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ struct dsa_switch_tree {
	 * protocol to use.
	 */
	struct net_device	*master_netdev;

	/* Copy of tag_ops->rcv for faster access in hot path */
	struct sk_buff *	(*rcv)(struct sk_buff *skb,
				       struct net_device *dev,
				       struct packet_type *pt,
@@ -465,16 +467,11 @@ struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);

struct net_device *dsa_dev_to_net_device(struct device *dev);

static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
{
	return dst->rcv != NULL;
}

/* Keep inline for faster access in hot path */
static inline bool netdev_uses_dsa(struct net_device *dev)
{
#if IS_ENABLED(CONFIG_NET_DSA)
	if (dev->dsa_ptr != NULL)
		return dsa_uses_tagged_protocol(dev->dsa_ptr);
	return dev->dsa_ptr && dev->dsa_ptr->rcv;
#endif
	return false;
}
+1 −1
Original line number Diff line number Diff line
@@ -454,7 +454,7 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
	 * sent to the tag format's receive function.
	 */
	wmb();
	dst->master_netdev->dsa_ptr = (void *)dst;
	dst->master_netdev->dsa_ptr = dst;
	dst->applied = true;

	return 0;
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ struct dsa_device_ops {
};

struct dsa_slave_priv {
	/* Copy of dp->ds->dst->tag_ops->xmit for faster access in hot path */
	struct sk_buff *	(*xmit)(struct sk_buff *skb,
					struct net_device *dev);

+1 −1
Original line number Diff line number Diff line
@@ -651,7 +651,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
	 * sent to the tag format's receive function.
	 */
	wmb();
	dev->dsa_ptr = (void *)dst;
	dev->dsa_ptr = dst;

	return 0;
}
+6 −2
Original line number Diff line number Diff line
@@ -357,10 +357,14 @@ static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
	dev->stats.tx_packets++;
	dev->stats.tx_bytes += skb->len;

	/* Transmit function may have to reallocate the original SKB */
	/* Transmit function may have to reallocate the original SKB,
	 * in which case it must have freed it. Only free it here on error.
	 */
	nskb = p->xmit(skb, dev);
	if (!nskb)
	if (!nskb) {
		kfree_skb(skb);
		return NETDEV_TX_OK;
	}

	/* SKB for netpoll still need to be mangled with the protocol-specific
	 * tag to be successfully transmitted
Loading