Skip to content

Commit 1f247a6

Browse files
tlfalcondavem330
authored andcommitted
ibmvnic: Pad small packets to minimum MTU size
Some backing devices cannot handle small packets well, so pad any small packets to avoid that. It was recommended that the VNIC driver should not send packets smaller than the minimum MTU value provided by firmware, so pad small packets to be at least that long. Signed-off-by: Thomas Falcon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8dff66c commit 1f247a6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,19 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff *txbuff,
13401340
txbuff->indir_arr + 1);
13411341
}
13421342

1343+
static int ibmvnic_xmit_workarounds(struct sk_buff *skb,
1344+
struct net_device *netdev)
1345+
{
1346+
/* For some backing devices, mishandling of small packets
1347+
* can result in a loss of connection or TX stall. Device
1348+
* architects recommend that no packet should be smaller
1349+
* than the minimum MTU value provided to the driver, so
1350+
* pad any packets to that length
1351+
*/
1352+
if (skb->len < netdev->min_mtu)
1353+
return skb_put_padto(skb, netdev->min_mtu);
1354+
}
1355+
13431356
static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
13441357
{
13451358
struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -1377,6 +1390,13 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
13771390
goto out;
13781391
}
13791392

1393+
if (ibmvnic_xmit_workarounds(skb, adapter)) {
1394+
tx_dropped++;
1395+
tx_send_failed++;
1396+
ret = NETDEV_TX_OK;
1397+
goto out;
1398+
}
1399+
13801400
tx_pool = &adapter->tx_pool[queue_num];
13811401
tx_scrq = adapter->tx_scrq[queue_num];
13821402
txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));

0 commit comments

Comments
 (0)