+++ /dev/null
-From foo@baz Sun Jun 17 12:13:49 CEST 2018
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Date: Thu, 19 Apr 2018 12:52:11 +0200
-Subject: s390/qeth: use Read device to query hypervisor for MAC
-
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-
-[ Upstream commit b7493e91c11a757cf0f8ab26989642ee4bb2c642 ]
-
-For z/VM NICs, qeth needs to consider which of the three CCW devices in
-an MPC group it uses for requesting a managed MAC address.
-
-On the Base device, the hypervisor returns a default MAC which is
-pre-assigned when creating the NIC (this MAC is also returned by the
-READ MAC primitive). Querying any other device results in the allocation
-of an additional MAC address.
-
-For consistency with READ MAC and to avoid using up more addresses than
-necessary, it is preferable to use the NIC's default MAC. So switch the
-the diag26c over to using a NIC's Read device, which should always be
-identical to the Base device.
-
-Fixes: ec61bd2fd2a2 ("s390/qeth: use diag26c to get MAC address on L2")
-Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----
- drivers/s390/net/qeth_core_main.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/s390/net/qeth_core_main.c
-+++ b/drivers/s390/net/qeth_core_main.c
-@@ -4837,7 +4837,7 @@ int qeth_vm_request_mac(struct qeth_card
- goto out;
- }
-
-- ccw_device_get_id(CARD_DDEV(card), &id);
-+ ccw_device_get_id(CARD_RDEV(card), &id);
- request->resp_buf_len = sizeof(*response);
- request->resp_version = DIAG26C_VERSION2;
- request->op_code = DIAG26C_GET_MAC;
+++ /dev/null
-From foo@baz Sun Jun 17 12:07:33 CEST 2018
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Date: Thu, 19 Apr 2018 12:52:09 +0200
-Subject: s390/qeth: fix MAC address update sequence
-
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-
-[ Upstream commit bcacfcbc82b4235d280ed9b067aa4567f4a0c756 ]
-
-When changing the MAC address on a L2 qeth device, current code first
-unregisters the old address, then registers the new one.
-If HW rejects the new address (or the IO fails), the device ends up with
-no operable address at all.
-
-Re-order the code flow so that the old address only gets dropped if the
-new address was registered successfully. While at it, add logic to catch
-some corner-cases.
-
-Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----
- drivers/s390/net/qeth_l2_main.c | 55 ++++++++++++++++++++++------------------
- 1 file changed, 31 insertions(+), 24 deletions(-)
-
---- a/drivers/s390/net/qeth_l2_main.c
-+++ b/drivers/s390/net/qeth_l2_main.c
-@@ -122,13 +122,10 @@ static int qeth_l2_send_setmac(struct qe
- QETH_CARD_TEXT(card, 2, "L2Setmac");
- rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC);
- if (rc == 0) {
-- card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
-- ether_addr_copy(card->dev->dev_addr, mac);
- dev_info(&card->gdev->dev,
-- "MAC address %pM successfully registered on device %s\n",
-- card->dev->dev_addr, card->dev->name);
-+ "MAC address %pM successfully registered on device %s\n",
-+ mac, card->dev->name);
- } else {
-- card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
- switch (rc) {
- case -EEXIST:
- dev_warn(&card->gdev->dev,
-@@ -143,19 +140,6 @@ static int qeth_l2_send_setmac(struct qe
- return rc;
- }
-
--static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac)
--{
-- int rc;
--
-- QETH_CARD_TEXT(card, 2, "L2Delmac");
-- if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
-- return 0;
-- rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_DELVMAC);
-- if (rc == 0)
-- card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
-- return rc;
--}
--
- static int qeth_l2_write_mac(struct qeth_card *card, u8 *mac)
- {
- enum qeth_ipa_cmds cmd = is_multicast_ether_addr_64bits(mac) ?
-@@ -522,6 +506,7 @@ static int qeth_l2_set_mac_address(struc
- {
- struct sockaddr *addr = p;
- struct qeth_card *card = dev->ml_priv;
-+ u8 old_addr[ETH_ALEN];
- int rc = 0;
-
- QETH_CARD_TEXT(card, 3, "setmac");
-@@ -533,14 +518,35 @@ static int qeth_l2_set_mac_address(struc
- return -EOPNOTSUPP;
- }
- QETH_CARD_HEX(card, 3, addr->sa_data, ETH_ALEN);
-+ if (!is_valid_ether_addr(addr->sa_data))
-+ return -EADDRNOTAVAIL;
-+
- if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
- QETH_CARD_TEXT(card, 3, "setmcREC");
- return -ERESTARTSYS;
- }
-- rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
-- if (!rc || (rc == -ENOENT))
-- rc = qeth_l2_send_setmac(card, addr->sa_data);
-- return rc ? -EINVAL : 0;
-+
-+ if (!qeth_card_hw_is_reachable(card)) {
-+ ether_addr_copy(dev->dev_addr, addr->sa_data);
-+ return 0;
-+ }
-+
-+ /* 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;
-+
-+ /* add the new address, switch over, drop the old */
-+ rc = qeth_l2_send_setmac(card, addr->sa_data);
-+ if (rc)
-+ return rc;
-+ 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;
- }
-
- static void qeth_promisc_to_bridge(struct qeth_card *card)
-@@ -1067,8 +1073,9 @@ static int __qeth_l2_set_online(struct c
- goto out_remove;
- }
-
-- if (card->info.type != QETH_CARD_TYPE_OSN)
-- qeth_l2_send_setmac(card, &card->dev->dev_addr[0]);
-+ if (card->info.type != QETH_CARD_TYPE_OSN &&
-+ !qeth_l2_send_setmac(card, card->dev->dev_addr))
-+ card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
-
- if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) {
- if (card->info.hwtrap &&
+++ /dev/null
-From foo@baz Sun Jun 17 12:07:33 CEST 2018
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Date: Thu, 19 Apr 2018 12:52:11 +0200
-Subject: s390/qeth: use Read device to query hypervisor for MAC
-
-From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-
-[ Upstream commit b7493e91c11a757cf0f8ab26989642ee4bb2c642 ]
-
-For z/VM NICs, qeth needs to consider which of the three CCW devices in
-an MPC group it uses for requesting a managed MAC address.
-
-On the Base device, the hypervisor returns a default MAC which is
-pre-assigned when creating the NIC (this MAC is also returned by the
-READ MAC primitive). Querying any other device results in the allocation
-of an additional MAC address.
-
-For consistency with READ MAC and to avoid using up more addresses than
-necessary, it is preferable to use the NIC's default MAC. So switch the
-the diag26c over to using a NIC's Read device, which should always be
-identical to the Base device.
-
-Fixes: ec61bd2fd2a2 ("s390/qeth: use diag26c to get MAC address on L2")
-Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----
- drivers/s390/net/qeth_core_main.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/s390/net/qeth_core_main.c
-+++ b/drivers/s390/net/qeth_core_main.c
-@@ -4839,7 +4839,7 @@ int qeth_vm_request_mac(struct qeth_card
- goto out;
- }
-
-- ccw_device_get_id(CARD_DDEV(card), &id);
-+ ccw_device_get_id(CARD_RDEV(card), &id);
- request->resp_buf_len = sizeof(*response);
- request->resp_version = DIAG26C_VERSION2;
- request->op_code = DIAG26C_GET_MAC;