mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
net: dsa: Refactor transmit path to eliminate duplication
All tagging protocols do the same thing: increment device statistics, make room for the tag to be inserted, create the tag, invoke the parent network device transmit function. In order to prepare for adding netpoll support, which requires the tag creation, but not using the parent network device transmit function, do some little refactoring which eliminates duplication between the 4 tagging protocols supported. We need to return a sk_buff pointer back to the caller because the tag specific transmit function may have to reallocate the original skb (e.g: tag_trailer.c) and this is the one we should be transmitting, not the original sk_buff we were passed. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6cec4f5e00
commit
4ed70ce9f0
6 changed files with 33 additions and 49 deletions
|
@ -421,21 +421,32 @@ static int dsa_slave_port_attr_get(struct net_device *dev,
|
|||
static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
struct dsa_slave_priv *p = netdev_priv(dev);
|
||||
struct sk_buff *nskb;
|
||||
|
||||
return p->xmit(skb, dev);
|
||||
}
|
||||
dev->stats.tx_packets++;
|
||||
dev->stats.tx_bytes += skb->len;
|
||||
|
||||
static netdev_tx_t dsa_slave_notag_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct dsa_slave_priv *p = netdev_priv(dev);
|
||||
/* Transmit function may have to reallocate the original SKB */
|
||||
nskb = p->xmit(skb, dev);
|
||||
if (!nskb)
|
||||
return NETDEV_TX_OK;
|
||||
|
||||
skb->dev = p->parent->dst->master_netdev;
|
||||
dev_queue_xmit(skb);
|
||||
/* Queue the SKB for transmission on the parent interface, but
|
||||
* do not modify its EtherType
|
||||
*/
|
||||
nskb->dev = p->parent->dst->master_netdev;
|
||||
dev_queue_xmit(nskb);
|
||||
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
/* Just return the original SKB */
|
||||
return skb;
|
||||
}
|
||||
|
||||
|
||||
/* ethtool operations *******************************************************/
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue