s390/qeth: fixes 2018-06-29
Subsystems (4)
cover s390/qeth: fixes 2018-06-29
Hi Dave,
please apply a few qeth fixes for -net and your 4.17 stable queue.
Patches 1-3 fix several issues wrt to MAC address management that were introduced during the 4.17 cycle.
Patch 4 tackles a long-standing issue with busy multi-connection workloads on devices in af_iucv mode.
Patch 5 makes sure to re-enable all active HW offloads, after a card was previously set offline and thus lost its HW context.
Thanks,
Julian
Julian Wiedmann (4):
Revert "s390/qeth: use Read device to query hypervisor for MAC" s390/qeth: fix race when setting MAC address s390/qeth: don't clobber buffer on async TX completion s390/qeth: consistently re-enable device features
Vasily Gorbik (1):
s390/qeth: avoid using is_multicast_ether_addr_64bits on (u8 *)[6]
drivers/s390/net/qeth_core.h | 13 ++++++++++- drivers/s390/net/qeth_core_main.c | 47 +++++++++++++++++++++++---------------- drivers/s390/net/qeth_l2_main.c | 24 ++++++++++++-------- drivers/s390/net/qeth_l3_main.c | 3 ++- 4 files changed, 57 insertions(+), 30 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/5 Revert "s390/qeth: use Read device to query hypervisor for MAC"
This reverts commit b7493e91c11a757cf0f8ab26989642ee4bb2c642.
On its own, querying RDEV for a MAC address works fine. But when upgrading from a qeth that previously queried DDEV on a z/VM NIC (ie. any kernel with commit ec61bd2fd2a2), the RDEV query now returns a _different_ MAC address than the DDEV query.
If the NIC is configured with MACPROTECT, z/VM apparently requires us to use the MAC that was initially returned (on DDEV) and registered. So after upgrading to a kernel that uses RDEV, the SETVMAC registration cmd for the new MAC address fails and we end up with a non-operabel interface.
To avoid regressions on upgrade, switch back to using DDEV for the MAC address query. The downgrade path (first RDEV, later DDEV) is fine, in this case both queries return the same MAC address.
--- drivers/s390/net/qeth_core_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +1 -1
@@ -4834,7 +4834,7 @@ int qeth_vm_request_mac(struct qeth_card *card) goto out; } -ccw_device_get_id (CARD_RDEV (card), &id); +ccw_device_get_id (CARD_DDEV (card), &id); request->resp_buf_len =sizeof (*response); request->resp_version =DIAG26C_VERSION2 ; request->op_code =DIAG26C_GET_MAC ;
Signature · 1 line
2.16.4
PATCH 2/5 s390/qeth: fix race when setting MAC address
In reply to Julian WiedmannWhen qeth_l2_set_mac_address() finds the card in a non-reachable state, it merely copies the new MAC address into dev->dev_addr so that __qeth_l2_set_online() can later register it with the HW.
But __qeth_l2_set_online() may very well be running concurrently, so we can't trust the card state without appropriate locking:
If the online sequence is past the point where it registers dev->dev_addr (but not yet in SOFTSETUP state), any address change needs to be properly programmed into the HW. Otherwise the netdevice ends up with a different MAC address than what's set in the HW, and inbound traffic is not forwarded as expected.
This is most likely to occur for OSD in LPAR, where
commit 21b1702af12e ("s390/qeth: improve fallback to random MAC address") now triggers eg. systemd to immediately change the MAC when the netdevice is registered with a NET_ADDR_RANDOM address.
--- drivers/s390/net/qeth_l2_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/s390/net/qeth_l2_main.c +11 -4
@@ -501,27 +501,34 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)return -ERESTARTSYS ; } +/* avoid racing against concurrent state change: */ +if (!mutex_trylock (&card->conf_mutex)) +return -EAGAIN ; +if (!qeth_card_hw_is_reachable (card)) {ether_addr_copy (dev->dev_addr, addr->sa_data); -return 0 ; + goto out_unlock; }/* don't register the same address twice */ if (ether_addr_equal_64bits (dev->dev_addr, addr->sa_data) && (card->info.mac_bits &QETH_LAYER2_MAC_REGISTERED )) -return 0 ; + goto out_unlock;/* add the new address, switch over, drop the old */ rc =qeth_l2_send_setmac (card, addr->sa_data);if (rc) -return rc; + goto out_unlock;ether_addr_copy (old_addr, dev->dev_addr);ether_addr_copy (dev->dev_addr, addr->sa_data);if (card->info.mac_bits &QETH_LAYER2_MAC_REGISTERED )qeth_l2_remove_mac (card, old_addr); card->info.mac_bits |=QETH_LAYER2_MAC_REGISTERED ; -return 0 ; + +out_unlock: +mutex_unlock (&card->conf_mutex); +return rc; }static void qeth_promisc_to_bridge (struct qeth_card *card)
Signature · 1 line
2.16.4
PATCH 3/5 s390/qeth: avoid using is_multicast_ether_addr_64bits on (u8 *)[6]
In reply to Julian WiedmannFrom: Vasily Gorbik <[email protected]>
*ether_addr*_64bits functions have been introduced to optimize performance critical paths, which access 6-byte ethernet address as u64 value to get "nice" assembly. A harmless hack works nicely on ethernet addresses shoved into a structure or a larger buffer, until busted by Kasan on smth like plain (u8 *)[6].
qeth_l2_set_mac_address calls qeth_l2_remove_mac passing u8 old_addr[ETH_ALEN] as an argument.
Adding/removing macs for an ethernet adapter is not that performance critical. Moreover is_multicast_ether_addr_64bits itself on s390 is not faster than is_multicast_ether_addr:
is_multicast_ether_addr(%r2) -> %r2
llc %r2,0(%r2)
risbg %r2,%r2,63,191,0
is_multicast_ether_addr_64bits(%r2) -> %r2
llgc %r2,0(%r2)
risbg %r2,%r2,63,191,0
So, let's just use is_multicast_ether_addr instead of is_multicast_ether_addr_64bits.
--- drivers/s390/net/qeth_l2_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/net/qeth_l2_main.c +2 -2
@@ -140,7 +140,7 @@ static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)static int qeth_l2_write_mac (struct qeth_card *card,u8 *mac) { -enum qeth_ipa_cmds cmd =is_multicast_ether_addr_64bits (mac) ? +enum qeth_ipa_cmds cmd =is_multicast_ether_addr (mac) ?IPA_CMD_SETGMAC :IPA_CMD_SETVMAC ;int rc;
@@ -157,7 +157,7 @@ static int qeth_l2_write_mac(struct qeth_card *card, u8 *mac)static int qeth_l2_remove_mac (struct qeth_card *card,u8 *mac) { -enum qeth_ipa_cmds cmd =is_multicast_ether_addr_64bits (mac) ? +enum qeth_ipa_cmds cmd =is_multicast_ether_addr (mac) ?IPA_CMD_DELGMAC :IPA_CMD_DELVMAC ;int rc;
Signature · 1 line
2.16.4
PATCH 4/5 s390/qeth: don't clobber buffer on async TX completion
In reply to Julian WiedmannIf qeth_qdio_output_handler() detects that a transmit requires async completion, it replaces the pending buffer's metadata object (qeth_qdio_out_buffer) so that this queue buffer can be re-used while the data is pending completion.
Later when the CQ indicates async completion of such a metadata object, qeth_qdio_cq_handler() tries to free any data associated with this object (since HW has now completed the transfer). By calling qeth_clear_output_buffer(), it erronously operates on the queue buffer that _previously_ belonged to this transfer ... but which has been potentially re-used several times by now.
This results in double-free's of the buffer's data, and failing transmits as the buffer descriptor is scrubbed in mid-air.
The correct way of handling this situation is to
1. scrub the queue buffer when it is prepared for re-use, and
2. later obtain the data addresses from the async-completion notifier (ie. the AOB), instead of the queue buffer.
All this only affects qeth devices used for af_iucv HiperTransport.
--- drivers/s390/net/qeth_core.h | 11 +++++++++++ drivers/s390/net/qeth_core_main.c | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-)
drivers/s390/net/qeth_core.h +11 -0
@@ -829,6 +829,17 @@ struct qeth_trap_id {/*some helper functions*/ #define QETH_CARD_IFNAME (card) (((card)->dev)? (card)->dev->name : "") +static inline void qeth_scrub_qdio_buffer (struct qdio_buffer *buf, +unsigned int elements) +{ +unsigned int i; + +for (i =0 ; i < elements; i++) +memset (&buf->element[i],0 ,sizeof (struct qdio_buffer_element )); + buf->element[14 ].sflags =0 ; + buf->element[15 ].sflags =0 ; +} +/** * qeth_get_elements_for_range() - find number of SBALEs to cover range. * @start: Start of the address range.
drivers/s390/net/qeth_core_main.c +16 -6
@@ -73,9 +73,6 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *queue,struct qeth_qdio_out_buffer *buf, enum iucv_tx_notify notification);static void qeth_release_skbs (struct qeth_qdio_out_buffer *buf); -static void qeth_clear_output_buffer (struct qeth_qdio_out_q *queue, -struct qeth_qdio_out_buffer *buf, -enum qeth_qdio_buffer_states newbufstate);static int qeth_init_qdio_out_buf (struct qeth_qdio_out_q *,int );struct workqueue_struct *qeth_wq;
@@ -489,6 +486,7 @@ static void qeth_qdio_handle_aob(struct qeth_card *card,struct qaob *aob;struct qeth_qdio_out_buffer *buffer;enum iucv_tx_notify notification; +unsigned int i; aob = (struct qaob *)phys_to_virt (phys_aob_addr);QETH_CARD_TEXT (card,5 ,"haob" );
@@ -513,10 +511,18 @@ static void qeth_qdio_handle_aob(struct qeth_card *card,qeth_notify_skbs (buffer->q, buffer, notification); buffer->aob =NULL ; -qeth_clear_output_buffer (buffer->q, buffer, -QETH_QDIO_BUF_HANDLED_DELAYED ); +/* Free dangling allocations. The attached skbs are handled by +* qeth_cleanup_handled_pending(). +*/ +for (i =0 ; + i < aob->sb_count && i <QETH_MAX_BUFFER_ELEMENTS (card); + i++) { +if (aob->sba[i] && buffer->is_header[i]) +kmem_cache_free (qeth_core_header_cache, + (void *) aob->sba[i]); + } +atomic_set (&buffer->state,QETH_QDIO_BUF_HANDLED_DELAYED ); -/* from here on: do not touch buffer anymore */ qdio_release_aob (aob); }
@@ -3759,6 +3765,10 @@ static void qeth_qdio_output_handler(struct ccw_device *ccwdev,QETH_CARD_TEXT (queue->card,5 ,"aob" );QETH_CARD_TEXT_ (queue->card,5 ,"%lx" ,virt_to_phys (buffer->aob)); + +/* prepare the queue slot for re-use: */ +qeth_scrub_qdio_buffer (buffer->buffer, +QETH_MAX_BUFFER_ELEMENTS (card));if (qeth_init_qdio_out_buf (queue, bidx)) {QETH_CARD_TEXT (card,2 ,"outofbuf" );qeth_schedule_recovery (card);
Signature · 1 line
2.16.4
PATCH 5/5 s390/qeth: consistently re-enable device features
In reply to Julian Wiedmanncommit e830baa9c3f0 ("qeth: restore device features after recovery") and commit ce3443564145 ("s390/qeth: rely on kernel for feature recovery") made sure that the HW functions for device features get re-programmed after recovery.
But we missed that the same handling is also required when a card is first set offline (destroying all HW context), and then online again. Fix this by moving the re-enable action out of the recovery-only path.
--- drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 23 +++++++++++------------ drivers/s390/net/qeth_l2_main.c | 5 ++--- drivers/s390/net/qeth_l3_main.c | 3 ++- 4 files changed, 16 insertions(+), 17 deletions(-)
drivers/s390/net/qeth_core.h +1 -1
@@ -1040,7 +1040,7 @@ struct qeth_cmd_buffer *qeth_get_setassparms_cmd(struct qeth_card *, __u16, __u16, enum qeth_prot_versions);int qeth_set_features (struct net_device *,netdev_features_t ); -void qeth_recover_features (struct net_device *dev); +void qeth_enable_hw_features (struct net_device *dev);netdev_features_t qeth_fix_features (struct net_device *,netdev_features_t ); netdev_features_t qeth_features_check(struct sk_buff *skb, struct net_device *dev,
drivers/s390/net/qeth_core_main.c +11 -12
@@ -6469,28 +6469,27 @@ static int qeth_set_ipa_rx_csum(struct qeth_card *card, bool on)#define QETH_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_TSO | \ NETIF_F_IPV6_CSUM)/** -* qeth_recover_features() - Restore device features after recovery -* @dev: the recovering net_device -* -* Caller must hold rtnl lock. +* qeth_enable_hw_features() - (Re-)Enable HW functions for device features +* @dev: a net_device */ -void qeth_recover_features (struct net_device *dev) +void qeth_enable_hw_features (struct net_device *dev) { -netdev_features_t features = dev->features;struct qeth_card *card = dev->ml_priv; +netdev_features_t features; +rtnl_lock (); + features = dev->features;/* force-off any feature that needs an IPA sequence. * netdev_update_features() will restart them. */ dev->features &= ~QETH_HW_FEATURES ;netdev_update_features (dev); - -if (features == dev->features) -return ; -dev_warn (&card->gdev->dev, -"Device recovery failed to restore all offload features\n" ); +if (features != dev->features) +dev_warn (&card->gdev->dev, +"Device recovery failed to restore all offload features\n" ); +rtnl_unlock (); } -EXPORT_SYMBOL_GPL (qeth_recover_features); +EXPORT_SYMBOL_GPL (qeth_enable_hw_features);int qeth_set_features (struct net_device *dev,netdev_features_t features) {
drivers/s390/net/qeth_l2_main.c +2 -3
@@ -1119,6 +1119,8 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode)netif_carrier_off (card->dev);qeth_set_allowed_threads (card,0xffffffff ,0 ); + +qeth_enable_hw_features (card->dev);if (recover_flag ==CARD_STATE_RECOVER ) {if (recovery_mode && card->info.type !=QETH_CARD_TYPE_OSN ) {
@@ -1130,9 +1132,6 @@ static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode) }/* this also sets saved unicast addresses */ qeth_l2_set_rx_mode (card->dev); -rtnl_lock (); -qeth_recover_features (card->dev); -rtnl_unlock (); }/* let user_space know that device is online */ kobject_uevent (&gdev->dev.kobj,KOBJ_CHANGE );
drivers/s390/net/qeth_l3_main.c +2 -1
@@ -2662,6 +2662,8 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)netif_carrier_on (card->dev); else netif_carrier_off(card->dev); + +qeth_enable_hw_features (card->dev);if (recover_flag ==CARD_STATE_RECOVER ) {rtnl_lock ();if (recovery_mode)
@@ -2669,7 +2671,6 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)else dev_open (card->dev);qeth_l3_set_rx_mode (card->dev); -qeth_recover_features (card->dev);rtnl_unlock (); }qeth_trace_features (card);
Signature · 1 line
2.16.4
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Fri, 29 Jun 2018 19:45:49 +0200
Quoted 8 lines
please apply a few qeth fixes for -net and your 4.17 stable queue.
Patches 1-3 fix several issues wrt to MAC address management that were introduced during the 4.17 cycle.
Patch 4 tackles a long-standing issue with busy multi-connection workloads on devices inaf_iucvmode.
Patch 5 makes sure to re-enable all active HW offloads, after a card was previously set offline and thus lost its HW context.
Series applied and queued up for -stable.