Skip to content

Commit 04ffcb2

Browse files
Tom Herbertdavem330
authored andcommitted
net: Add ndo_gso_check
Add ndo_gso_check which a device can define to indicate whether is is capable of doing GSO on a packet. This funciton would be called from the stack to determine whether software GSO is needed to be done. A driver should populate this function if it advertises GSO types for which there are combinations that it wouldn't be able to handle. For instance a device that performs UDP tunneling might only implement support for transparent Ethernet bridging type of inner packets or might have limitations on lengths of inner headers. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 71ae8f5 commit 04ffcb2

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎drivers/net/macvtap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static rx_handler_result_t macvtap_handle_frame(struct sk_buff **pskb)
298298
*/
299299
if (q->flags & IFF_VNET_HDR)
300300
features |= vlan->tap_features;
301-
if (netif_needs_gso(skb, features)) {
301+
if (netif_needs_gso(dev, skb, features)) {
302302
struct sk_buff *segs = __skb_gso_segment(skb, features, false);
303303

304304
if (IS_ERR(segs))

‎drivers/net/xen-netfront.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
638638

639639
if (unlikely(!netif_carrier_ok(dev) ||
640640
(slots > 1 && !xennet_can_sg(dev)) ||
641-
netif_needs_gso(skb, netif_skb_features(skb)))) {
641+
netif_needs_gso(dev, skb, netif_skb_features(skb)))) {
642642
spin_unlock_irqrestore(&queue->tx_lock, flags);
643643
goto drop;
644644
}

‎include/linux/netdevice.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
998998
* Callback to use for xmit over the accelerated station. This
999999
* is used in place of ndo_start_xmit on accelerated net
10001000
* devices.
1001+
* bool (*ndo_gso_check) (struct sk_buff *skb,
1002+
* struct net_device *dev);
1003+
* Called by core transmit path to determine if device is capable of
1004+
* performing GSO on a packet. The device returns true if it is
1005+
* able to GSO the packet, false otherwise. If the return value is
1006+
* false the stack will do software GSO.
10011007
*/
10021008
struct net_device_ops {
10031009
int (*ndo_init)(struct net_device *dev);
@@ -1147,6 +1153,8 @@ struct net_device_ops {
11471153
struct net_device *dev,
11481154
void *priv);
11491155
int (*ndo_get_lock_subclass)(struct net_device *dev);
1156+
bool (*ndo_gso_check) (struct sk_buff *skb,
1157+
struct net_device *dev);
11501158
};
11511159

11521160
/**
@@ -3572,10 +3580,12 @@ static inline bool skb_gso_ok(struct sk_buff *skb, netdev_features_t features)
35723580
(!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST));
35733581
}
35743582

3575-
static inline bool netif_needs_gso(struct sk_buff *skb,
3583+
static inline bool netif_needs_gso(struct net_device *dev, struct sk_buff *skb,
35763584
netdev_features_t features)
35773585
{
35783586
return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
3587+
(dev->netdev_ops->ndo_gso_check &&
3588+
!dev->netdev_ops->ndo_gso_check(skb, dev)) ||
35793589
unlikely((skb->ip_summed != CHECKSUM_PARTIAL) &&
35803590
(skb->ip_summed != CHECKSUM_UNNECESSARY)));
35813591
}

‎net/core/dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
26752675
if (skb->encapsulation)
26762676
features &= dev->hw_enc_features;
26772677

2678-
if (netif_needs_gso(skb, features)) {
2678+
if (netif_needs_gso(dev, skb, features)) {
26792679
struct sk_buff *segs;
26802680

26812681
segs = skb_gso_segment(skb, features);

0 commit comments

Comments
 (0)