netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata
@ 2018-03-12 16:51 Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 1/4] ibmvnic: Account for VLAN tag in L2 Header descriptor Thomas Falcon
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 16:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, jallen, nfont, Thomas Falcon

This patch series contains fixes for VLAN and other backing hardware
errata. The VLAN fixes are mostly to account for the additional four
bytes VLAN header in TX descriptors and buffers, when applicable.

The other fixes for device errata are to pad small packets to avoid a
possible connection error that can occur when some devices attempt to
transmit small packets. The other fixes are GSO related. Some devices
cannot handle a smaller MSS or a packet with a single segment, so
disable GSO in those cases.

v2: Fix style mistake (unneeded brackets) in patch 3/4

Thomas Falcon (4):
  ibmvnic: Account for VLAN tag in L2 Header descriptor
  ibmvnic: Account for VLAN header length in TX buffers
  ibmvnic: Pad small packets to minimum MTU size
  ibmvnic: Handle TSO backing device errata

 drivers/net/ethernet/ibm/ibmvnic.c | 50 +++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 4 deletions(-)

-- 
2.12.3

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 1/4] ibmvnic: Account for VLAN tag in L2 Header descriptor
  2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
@ 2018-03-12 16:51 ` Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 2/4] ibmvnic: Account for VLAN header length in TX buffers Thomas Falcon
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 16:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, jallen, nfont, Thomas Falcon

If a VLAN tag is present in the Ethernet header, account
for that when providing the L2 header to firmware.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 7be4b06..ea9f351 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1221,7 +1221,10 @@ static int build_hdr_data(u8 hdr_field, struct sk_buff *skb,
 	int len = 0;
 	u8 *hdr;
 
-	hdr_len[0] = sizeof(struct ethhdr);
+	if (skb_vlan_tagged(skb) && !skb_vlan_tag_present(skb))
+		hdr_len[0] = sizeof(struct vlan_ethhdr);
+	else
+		hdr_len[0] = sizeof(struct ethhdr);
 
 	if (skb->protocol == htons(ETH_P_IP)) {
 		hdr_len[1] = ip_hdr(skb)->ihl * 4;
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 2/4] ibmvnic: Account for VLAN header length in TX buffers
  2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 1/4] ibmvnic: Account for VLAN tag in L2 Header descriptor Thomas Falcon
@ 2018-03-12 16:51 ` Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size Thomas Falcon
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 16:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, jallen, nfont, Thomas Falcon

The extra four bytes of a VLAN packet was throwing off
TX buffer entry values used by the driver. Account for those
bytes when in buffer size and buffer entry calculations

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index ea9f351..14f0081 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -659,7 +659,7 @@ static int init_tx_pools(struct net_device *netdev)
 
 		if (alloc_long_term_buff(adapter, &tx_pool->long_term_buff,
 					 adapter->req_tx_entries_per_subcrq *
-					 adapter->req_mtu)) {
+					 (adapter->req_mtu + VLAN_HLEN))) {
 			release_tx_pools(adapter);
 			return -1;
 		}
@@ -1394,9 +1394,9 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		if (tx_pool->tso_index == IBMVNIC_TSO_BUFS)
 			tx_pool->tso_index = 0;
 	} else {
-		offset = index * adapter->req_mtu;
+		offset = index * (adapter->req_mtu + VLAN_HLEN);
 		dst = tx_pool->long_term_buff.buff + offset;
-		memset(dst, 0, adapter->req_mtu);
+		memset(dst, 0, adapter->req_mtu + VLAN_HLEN);
 		data_dma_addr = tx_pool->long_term_buff.addr + offset;
 	}
 
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size
  2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 1/4] ibmvnic: Account for VLAN tag in L2 Header descriptor Thomas Falcon
  2018-03-12 16:51 ` [PATCH net-next v2 2/4] ibmvnic: Account for VLAN header length in TX buffers Thomas Falcon
@ 2018-03-12 16:51 ` Thomas Falcon
  2018-03-13  7:15   ` kbuild test robot
  2018-03-12 16:51 ` [PATCH net-next v2 4/4] ibmvnic: Handle TSO backing device errata Thomas Falcon
  2018-03-12 16:56 ` [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other " David Miller
  4 siblings, 1 reply; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 16:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, jallen, nfont, Thomas Falcon

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 <tlfalcon@linux.vnet.ibm.com>
---
v2: Fix up unneeded brackets
 drivers/net/ethernet/ibm/ibmvnic.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 14f0081..7ed87fb 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1340,6 +1340,19 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff *txbuff,
 			 txbuff->indir_arr + 1);
 }
 
+static int ibmvnic_xmit_workarounds(struct sk_buff *skb,
+				    struct net_device *netdev)
+{
+	/* For some backing devices, mishandling of small packets
+	 * can result in a loss of connection or TX stall. Device
+	 * architects recommend that no packet should be smaller
+	 * than the minimum MTU value provided to the driver, so
+	 * pad any packets to that length
+	 */
+	if (skb->len < netdev->min_mtu)
+		return skb_put_padto(skb, netdev->min_mtu);
+}
+
 static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
@@ -1377,6 +1390,13 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
 		goto out;
 	}
 
+	if (ibmvnic_xmit_workarounds(skb, adapter)) {
+		tx_dropped++;
+		tx_send_failed++;
+		ret = NETDEV_TX_OK;
+		goto out;
+	}
+
 	tx_pool = &adapter->tx_pool[queue_num];
 	tx_scrq = adapter->tx_scrq[queue_num];
 	txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next v2 4/4] ibmvnic: Handle TSO backing device errata
  2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
                   ` (2 preceding siblings ...)
  2018-03-12 16:51 ` [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size Thomas Falcon
@ 2018-03-12 16:51 ` Thomas Falcon
  2018-03-12 16:56 ` [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other " David Miller
  4 siblings, 0 replies; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 16:51 UTC (permalink / raw)
  To: netdev; +Cc: davem, jallen, nfont, Thomas Falcon

TSO packets with one segment or with an MSS less than 224 can
cause errors on some backing devices, so disable GSO in those cases.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 7ed87fb..e02d3b9 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2049,6 +2049,23 @@ static int ibmvnic_change_mtu(struct net_device *netdev, int new_mtu)
 	return wait_for_reset(adapter);
 }
 
+static netdev_features_t ibmvnic_features_check(struct sk_buff *skb,
+						struct net_device *dev,
+						netdev_features_t features)
+{
+	/* Some backing hardware adapters can not
+	 * handle packets with a MSS less than 224
+	 * or with only one segment.
+	 */
+	if (skb_is_gso(skb)) {
+		if (skb_shinfo(skb)->gso_size < 224 ||
+		    skb_shinfo(skb)->gso_segs == 1)
+			features &= ~NETIF_F_GSO_MASK;
+	}
+
+	return features;
+}
+
 static const struct net_device_ops ibmvnic_netdev_ops = {
 	.ndo_open		= ibmvnic_open,
 	.ndo_stop		= ibmvnic_close,
@@ -2061,6 +2078,7 @@ static const struct net_device_ops ibmvnic_netdev_ops = {
 	.ndo_poll_controller	= ibmvnic_netpoll_controller,
 #endif
 	.ndo_change_mtu		= ibmvnic_change_mtu,
+	.ndo_features_check     = ibmvnic_features_check,
 };
 
 /* ethtool functions */
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata
  2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
                   ` (3 preceding siblings ...)
  2018-03-12 16:51 ` [PATCH net-next v2 4/4] ibmvnic: Handle TSO backing device errata Thomas Falcon
@ 2018-03-12 16:56 ` David Miller
  2018-03-12 22:07   ` Thomas Falcon
  4 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2018-03-12 16:56 UTC (permalink / raw)
  To: tlfalcon; +Cc: netdev, jallen, nfont

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Mon, 12 Mar 2018 11:51:01 -0500

> This patch series contains fixes for VLAN and other backing hardware
> errata. The VLAN fixes are mostly to account for the additional four
> bytes VLAN header in TX descriptors and buffers, when applicable.
> 
> The other fixes for device errata are to pad small packets to avoid a
> possible connection error that can occur when some devices attempt to
> transmit small packets. The other fixes are GSO related. Some devices
> cannot handle a smaller MSS or a packet with a single segment, so
> disable GSO in those cases.
> 
> v2: Fix style mistake (unneeded brackets) in patch 3/4

Series applied, thanks Thomas.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata
  2018-03-12 16:56 ` [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other " David Miller
@ 2018-03-12 22:07   ` Thomas Falcon
  2018-03-13  0:59     ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Falcon @ 2018-03-12 22:07 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, jallen, nfont

On 03/12/2018 11:56 AM, David Miller wrote:
> From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
> Date: Mon, 12 Mar 2018 11:51:01 -0500
>
>> This patch series contains fixes for VLAN and other backing hardware
>> errata. The VLAN fixes are mostly to account for the additional four
>> bytes VLAN header in TX descriptors and buffers, when applicable.
>>
>> The other fixes for device errata are to pad small packets to avoid a
>> possible connection error that can occur when some devices attempt to
>> transmit small packets. The other fixes are GSO related. Some devices
>> cannot handle a smaller MSS or a packet with a single segment, so
>> disable GSO in those cases.
>>
>> v2: Fix style mistake (unneeded brackets) in patch 3/4
> Series applied, thanks Thomas.
>
Really sorry about this, but 3/4 is still wrong.  There is actually a compiler warning caused by it, which I'm surprised wasn't caught by the test robot.  Is there still time to send a v3?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata
  2018-03-12 22:07   ` Thomas Falcon
@ 2018-03-13  0:59     ` David Miller
  2018-03-13  1:00       ` Thomas Falcon
  0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2018-03-13  0:59 UTC (permalink / raw)
  To: tlfalcon; +Cc: netdev, jallen, nfont

From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Mon, 12 Mar 2018 17:07:38 -0500

> On 03/12/2018 11:56 AM, David Miller wrote:
>> From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
>> Date: Mon, 12 Mar 2018 11:51:01 -0500
>>
>>> This patch series contains fixes for VLAN and other backing hardware
>>> errata. The VLAN fixes are mostly to account for the additional four
>>> bytes VLAN header in TX descriptors and buffers, when applicable.
>>>
>>> The other fixes for device errata are to pad small packets to avoid a
>>> possible connection error that can occur when some devices attempt to
>>> transmit small packets. The other fixes are GSO related. Some devices
>>> cannot handle a smaller MSS or a packet with a single segment, so
>>> disable GSO in those cases.
>>>
>>> v2: Fix style mistake (unneeded brackets) in patch 3/4
>> Series applied, thanks Thomas.
>>
> Really sorry about this, but 3/4 is still wrong.  There is actually a compiler warning caused by it, which I'm surprised wasn't caught by the test robot.  Is there still time to send a v3?

If it's in my tree you must send a fixup patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata
  2018-03-13  0:59     ` David Miller
@ 2018-03-13  1:00       ` Thomas Falcon
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Falcon @ 2018-03-13  1:00 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, jallen, nfont

On 03/12/2018 07:59 PM, David Miller wrote:
> From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
> Date: Mon, 12 Mar 2018 17:07:38 -0500
>
>> On 03/12/2018 11:56 AM, David Miller wrote:
>>> From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
>>> Date: Mon, 12 Mar 2018 11:51:01 -0500
>>>
>>>> This patch series contains fixes for VLAN and other backing hardware
>>>> errata. The VLAN fixes are mostly to account for the additional four
>>>> bytes VLAN header in TX descriptors and buffers, when applicable.
>>>>
>>>> The other fixes for device errata are to pad small packets to avoid a
>>>> possible connection error that can occur when some devices attempt to
>>>> transmit small packets. The other fixes are GSO related. Some devices
>>>> cannot handle a smaller MSS or a packet with a single segment, so
>>>> disable GSO in those cases.
>>>>
>>>> v2: Fix style mistake (unneeded brackets) in patch 3/4
>>> Series applied, thanks Thomas.
>>>
>> Really sorry about this, but 3/4 is still wrong.  There is actually a compiler warning caused by it, which I'm surprised wasn't caught by the test robot.  Is there still time to send a v3?
> If it's in my tree you must send a fixup patch.
>
Thanks, I will do that shortly.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size
  2018-03-12 16:51 ` [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size Thomas Falcon
@ 2018-03-13  7:15   ` kbuild test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2018-03-13  7:15 UTC (permalink / raw)
  To: Thomas Falcon; +Cc: kbuild-all, netdev, davem, jallen, nfont, Thomas Falcon

[-- Attachment #1: Type: text/plain, Size: 10072 bytes --]

Hi Thomas,

I love your patch! Yet something to improve:

[auto build test ERROR on v4.16-rc4]
[also build test ERROR on next-20180309]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Thomas-Falcon/ibmvnic-Fix-VLAN-and-other-device-errata/20180313-125518
config: powerpc-allmodconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/ibm/ibmvnic.c: In function 'ibmvnic_xmit':
>> drivers/net/ethernet/ibm/ibmvnic.c:1386:36: error: passing argument 2 of 'ibmvnic_xmit_workarounds' from incompatible pointer type [-Werror=incompatible-pointer-types]
     if (ibmvnic_xmit_workarounds(skb, adapter)) {
                                       ^~~~~~~
   drivers/net/ethernet/ibm/ibmvnic.c:1336:12: note: expected 'struct net_device *' but argument is of type 'struct ibmvnic_adapter *'
    static int ibmvnic_xmit_workarounds(struct sk_buff *skb,
               ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/ibm/ibmvnic.c: In function 'ibmvnic_xmit_workarounds':
>> drivers/net/ethernet/ibm/ibmvnic.c:1347:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +/ibmvnic_xmit_workarounds +1386 drivers/net/ethernet/ibm/ibmvnic.c

  1335	
  1336	static int ibmvnic_xmit_workarounds(struct sk_buff *skb,
  1337					    struct net_device *netdev)
  1338	{
  1339		/* For some backing devices, mishandling of small packets
  1340		 * can result in a loss of connection or TX stall. Device
  1341		 * architects recommend that no packet should be smaller
  1342		 * than the minimum MTU value provided to the driver, so
  1343		 * pad any packets to that length
  1344		 */
  1345		if (skb->len < netdev->min_mtu)
  1346			return skb_put_padto(skb, netdev->min_mtu);
> 1347	}
  1348	
  1349	static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
  1350	{
  1351		struct ibmvnic_adapter *adapter = netdev_priv(netdev);
  1352		int queue_num = skb_get_queue_mapping(skb);
  1353		u8 *hdrs = (u8 *)&adapter->tx_rx_desc_req;
  1354		struct device *dev = &adapter->vdev->dev;
  1355		struct ibmvnic_tx_buff *tx_buff = NULL;
  1356		struct ibmvnic_sub_crq_queue *tx_scrq;
  1357		struct ibmvnic_tx_pool *tx_pool;
  1358		unsigned int tx_send_failed = 0;
  1359		unsigned int tx_map_failed = 0;
  1360		unsigned int tx_dropped = 0;
  1361		unsigned int tx_packets = 0;
  1362		unsigned int tx_bytes = 0;
  1363		dma_addr_t data_dma_addr;
  1364		struct netdev_queue *txq;
  1365		unsigned long lpar_rc;
  1366		union sub_crq tx_crq;
  1367		unsigned int offset;
  1368		int num_entries = 1;
  1369		unsigned char *dst;
  1370		u64 *handle_array;
  1371		int index = 0;
  1372		u8 proto = 0;
  1373		int ret = 0;
  1374	
  1375		if (adapter->resetting) {
  1376			if (!netif_subqueue_stopped(netdev, skb))
  1377				netif_stop_subqueue(netdev, queue_num);
  1378			dev_kfree_skb_any(skb);
  1379	
  1380			tx_send_failed++;
  1381			tx_dropped++;
  1382			ret = NETDEV_TX_OK;
  1383			goto out;
  1384		}
  1385	
> 1386		if (ibmvnic_xmit_workarounds(skb, adapter)) {
  1387			tx_dropped++;
  1388			tx_send_failed++;
  1389			ret = NETDEV_TX_OK;
  1390			goto out;
  1391		}
  1392	
  1393		tx_pool = &adapter->tx_pool[queue_num];
  1394		tx_scrq = adapter->tx_scrq[queue_num];
  1395		txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb));
  1396		handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
  1397			be32_to_cpu(adapter->login_rsp_buf->off_txsubm_subcrqs));
  1398	
  1399		index = tx_pool->free_map[tx_pool->consumer_index];
  1400	
  1401		if (skb_is_gso(skb)) {
  1402			offset = tx_pool->tso_index * IBMVNIC_TSO_BUF_SZ;
  1403			dst = tx_pool->tso_ltb.buff + offset;
  1404			memset(dst, 0, IBMVNIC_TSO_BUF_SZ);
  1405			data_dma_addr = tx_pool->tso_ltb.addr + offset;
  1406			tx_pool->tso_index++;
  1407			if (tx_pool->tso_index == IBMVNIC_TSO_BUFS)
  1408				tx_pool->tso_index = 0;
  1409		} else {
  1410			offset = index * (adapter->req_mtu + VLAN_HLEN);
  1411			dst = tx_pool->long_term_buff.buff + offset;
  1412			memset(dst, 0, adapter->req_mtu + VLAN_HLEN);
  1413			data_dma_addr = tx_pool->long_term_buff.addr + offset;
  1414		}
  1415	
  1416		if (skb_shinfo(skb)->nr_frags) {
  1417			int cur, i;
  1418	
  1419			/* Copy the head */
  1420			skb_copy_from_linear_data(skb, dst, skb_headlen(skb));
  1421			cur = skb_headlen(skb);
  1422	
  1423			/* Copy the frags */
  1424			for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
  1425				const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
  1426	
  1427				memcpy(dst + cur,
  1428				       page_address(skb_frag_page(frag)) +
  1429				       frag->page_offset, skb_frag_size(frag));
  1430				cur += skb_frag_size(frag);
  1431			}
  1432		} else {
  1433			skb_copy_from_linear_data(skb, dst, skb->len);
  1434		}
  1435	
  1436		tx_pool->consumer_index =
  1437		    (tx_pool->consumer_index + 1) %
  1438			adapter->req_tx_entries_per_subcrq;
  1439	
  1440		tx_buff = &tx_pool->tx_buff[index];
  1441		tx_buff->skb = skb;
  1442		tx_buff->data_dma[0] = data_dma_addr;
  1443		tx_buff->data_len[0] = skb->len;
  1444		tx_buff->index = index;
  1445		tx_buff->pool_index = queue_num;
  1446		tx_buff->last_frag = true;
  1447	
  1448		memset(&tx_crq, 0, sizeof(tx_crq));
  1449		tx_crq.v1.first = IBMVNIC_CRQ_CMD;
  1450		tx_crq.v1.type = IBMVNIC_TX_DESC;
  1451		tx_crq.v1.n_crq_elem = 1;
  1452		tx_crq.v1.n_sge = 1;
  1453		tx_crq.v1.flags1 = IBMVNIC_TX_COMP_NEEDED;
  1454		tx_crq.v1.correlator = cpu_to_be32(index);
  1455		if (skb_is_gso(skb))
  1456			tx_crq.v1.dma_reg = cpu_to_be16(tx_pool->tso_ltb.map_id);
  1457		else
  1458			tx_crq.v1.dma_reg = cpu_to_be16(tx_pool->long_term_buff.map_id);
  1459		tx_crq.v1.sge_len = cpu_to_be32(skb->len);
  1460		tx_crq.v1.ioba = cpu_to_be64(data_dma_addr);
  1461	
  1462		if (adapter->vlan_header_insertion) {
  1463			tx_crq.v1.flags2 |= IBMVNIC_TX_VLAN_INSERT;
  1464			tx_crq.v1.vlan_id = cpu_to_be16(skb->vlan_tci);
  1465		}
  1466	
  1467		if (skb->protocol == htons(ETH_P_IP)) {
  1468			tx_crq.v1.flags1 |= IBMVNIC_TX_PROT_IPV4;
  1469			proto = ip_hdr(skb)->protocol;
  1470		} else if (skb->protocol == htons(ETH_P_IPV6)) {
  1471			tx_crq.v1.flags1 |= IBMVNIC_TX_PROT_IPV6;
  1472			proto = ipv6_hdr(skb)->nexthdr;
  1473		}
  1474	
  1475		if (proto == IPPROTO_TCP)
  1476			tx_crq.v1.flags1 |= IBMVNIC_TX_PROT_TCP;
  1477		else if (proto == IPPROTO_UDP)
  1478			tx_crq.v1.flags1 |= IBMVNIC_TX_PROT_UDP;
  1479	
  1480		if (skb->ip_summed == CHECKSUM_PARTIAL) {
  1481			tx_crq.v1.flags1 |= IBMVNIC_TX_CHKSUM_OFFLOAD;
  1482			hdrs += 2;
  1483		}
  1484		if (skb_is_gso(skb)) {
  1485			tx_crq.v1.flags1 |= IBMVNIC_TX_LSO;
  1486			tx_crq.v1.mss = cpu_to_be16(skb_shinfo(skb)->gso_size);
  1487			hdrs += 2;
  1488		}
  1489		/* determine if l2/3/4 headers are sent to firmware */
  1490		if ((*hdrs >> 7) & 1) {
  1491			build_hdr_descs_arr(tx_buff, &num_entries, *hdrs);
  1492			tx_crq.v1.n_crq_elem = num_entries;
  1493			tx_buff->indir_arr[0] = tx_crq;
  1494			tx_buff->indir_dma = dma_map_single(dev, tx_buff->indir_arr,
  1495							    sizeof(tx_buff->indir_arr),
  1496							    DMA_TO_DEVICE);
  1497			if (dma_mapping_error(dev, tx_buff->indir_dma)) {
  1498				dev_kfree_skb_any(skb);
  1499				tx_buff->skb = NULL;
  1500				if (!firmware_has_feature(FW_FEATURE_CMO))
  1501					dev_err(dev, "tx: unable to map descriptor array\n");
  1502				tx_map_failed++;
  1503				tx_dropped++;
  1504				ret = NETDEV_TX_OK;
  1505				goto out;
  1506			}
  1507			lpar_rc = send_subcrq_indirect(adapter, handle_array[queue_num],
  1508						       (u64)tx_buff->indir_dma,
  1509						       (u64)num_entries);
  1510		} else {
  1511			lpar_rc = send_subcrq(adapter, handle_array[queue_num],
  1512					      &tx_crq);
  1513		}
  1514		if (lpar_rc != H_SUCCESS) {
  1515			dev_err(dev, "tx failed with code %ld\n", lpar_rc);
  1516	
  1517			if (tx_pool->consumer_index == 0)
  1518				tx_pool->consumer_index =
  1519					adapter->req_tx_entries_per_subcrq - 1;
  1520			else
  1521				tx_pool->consumer_index--;
  1522	
  1523			dev_kfree_skb_any(skb);
  1524			tx_buff->skb = NULL;
  1525	
  1526			if (lpar_rc == H_CLOSED) {
  1527				/* Disable TX and report carrier off if queue is closed.
  1528				 * Firmware guarantees that a signal will be sent to the
  1529				 * driver, triggering a reset or some other action.
  1530				 */
  1531				netif_tx_stop_all_queues(netdev);
  1532				netif_carrier_off(netdev);
  1533			}
  1534	
  1535			tx_send_failed++;
  1536			tx_dropped++;
  1537			ret = NETDEV_TX_OK;
  1538			goto out;
  1539		}
  1540	
  1541		if (atomic_inc_return(&tx_scrq->used)
  1542						>= adapter->req_tx_entries_per_subcrq) {
  1543			netdev_info(netdev, "Stopping queue %d\n", queue_num);
  1544			netif_stop_subqueue(netdev, queue_num);
  1545		}
  1546	
  1547		tx_packets++;
  1548		tx_bytes += skb->len;
  1549		txq->trans_start = jiffies;
  1550		ret = NETDEV_TX_OK;
  1551	
  1552	out:
  1553		netdev->stats.tx_dropped += tx_dropped;
  1554		netdev->stats.tx_bytes += tx_bytes;
  1555		netdev->stats.tx_packets += tx_packets;
  1556		adapter->tx_send_failed += tx_send_failed;
  1557		adapter->tx_map_failed += tx_map_failed;
  1558		adapter->tx_stats_buffers[queue_num].packets += tx_packets;
  1559		adapter->tx_stats_buffers[queue_num].bytes += tx_bytes;
  1560		adapter->tx_stats_buffers[queue_num].dropped_packets += tx_dropped;
  1561	
  1562		return ret;
  1563	}
  1564	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56598 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-03-13  7:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 16:51 [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other device errata Thomas Falcon
2018-03-12 16:51 ` [PATCH net-next v2 1/4] ibmvnic: Account for VLAN tag in L2 Header descriptor Thomas Falcon
2018-03-12 16:51 ` [PATCH net-next v2 2/4] ibmvnic: Account for VLAN header length in TX buffers Thomas Falcon
2018-03-12 16:51 ` [PATCH net-next v2 3/4] ibmvnic: Pad small packets to minimum MTU size Thomas Falcon
2018-03-13  7:15   ` kbuild test robot
2018-03-12 16:51 ` [PATCH net-next v2 4/4] ibmvnic: Handle TSO backing device errata Thomas Falcon
2018-03-12 16:56 ` [PATCH net-next v2 0/4] ibmvnic: Fix VLAN and other " David Miller
2018-03-12 22:07   ` Thomas Falcon
2018-03-13  0:59     ` David Miller
2018-03-13  1:00       ` Thomas Falcon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).