s390/qeth: updates 2017-12-27
Subsystems (4)
cover s390/qeth: updates 2017-12-27
Hi Dave,
please apply some post-christmas leftovers for 4.16.
Two patches to improve IP address management on L3, and two that add support to auto-config the transport mode on z/VM VNICs. Note that one patch in the series touches arch/s390 (acked by Martin).
Thanks,
Julian
Julian Wiedmann (4):
s390/qeth: improve error reporting on IP add/removal s390/qeth: use common helper to display rxip/vipa s390/diag: add diag26c support for VNIC info s390/qeth: support early setup for z/VM NICs
arch/s390/include/asm/diag.h | 44 +++++++++++++++- drivers/s390/net/qeth_core_main.c | 86 ++++++++++++++++++++++++++++---- drivers/s390/net/qeth_l3.h | 12 +++-- drivers/s390/net/qeth_l3_main.c | 36 ++++++++------ drivers/s390/net/qeth_l3_sys.c | 102 +++++++++++--------------------------- 5 files changed, 179 insertions(+), 101 deletions(-)
Signature · 1 line
2.13.5
PATCH 1/4 s390/qeth: improve error reporting on IP add/removal
When adding & removing IP entries for rxip/vipa/ipato/hsuid, forward any resulting errors back to the sysfs-level caller.
--- drivers/s390/net/qeth_l3.h | 12 +++++++----- drivers/s390/net/qeth_l3_main.c | 36 ++++++++++++++++++++++-------------- drivers/s390/net/qeth_l3_sys.c | 12 ++++++------ 3 files changed, 35 insertions(+), 25 deletions(-)
drivers/s390/net/qeth_l3.h +7 -5
@@ -74,13 +74,15 @@ void qeth_l3_remove_device_attributes(struct device *);int qeth_l3_setrouting_v4 (struct qeth_card *);int qeth_l3_setrouting_v6 (struct qeth_card *);int qeth_l3_add_ipato_entry (struct qeth_card *,struct qeth_ipato_entry *); -void qeth_l3_del_ipato_entry (struct qeth_card *,enum qeth_prot_versions , -u8 *,int ); +int qeth_l3_del_ipato_entry (struct qeth_card *card, +enum qeth_prot_versions proto,u8 *addr, +int mask_bits);int qeth_l3_add_vipa (struct qeth_card *,enum qeth_prot_versions ,const u8 *); -void qeth_l3_del_vipa (struct qeth_card *,enum qeth_prot_versions ,const u8 *); +int qeth_l3_del_vipa (struct qeth_card *card,enum qeth_prot_versions proto, +const u8 *addr);int qeth_l3_add_rxip (struct qeth_card *,enum qeth_prot_versions ,const u8 *); -void qeth_l3_del_rxip (struct qeth_card *card,enum qeth_prot_versions , -const u8 *); +int qeth_l3_del_rxip (struct qeth_card *card,enum qeth_prot_versions proto, +const u8 *addr);void qeth_l3_update_ipato (struct qeth_card *card);struct qeth_ipaddr *qeth_l3_get_addr_buffer (enum qeth_prot_versions );int qeth_l3_add_ip (struct qeth_card *,struct qeth_ipaddr *);
drivers/s390/net/qeth_l3_main.c +22 -14
@@ -588,10 +588,12 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card,return rc; } -void qeth_l3_del_ipato_entry (struct qeth_card *card, -enum qeth_prot_versions proto,u8 *addr,int mask_bits) +int qeth_l3_del_ipato_entry (struct qeth_card *card, +enum qeth_prot_versions proto,u8 *addr, +int mask_bits) {struct qeth_ipato_entry *ipatoe, *tmp; +int rc = -ENOENT ;QETH_CARD_TEXT (card,2 ,"delipato" );
@@ -606,10 +608,12 @@ void qeth_l3_del_ipato_entry(struct qeth_card *card,list_del (&ipatoe->entry);qeth_l3_update_ipato (card);kfree (ipatoe); + rc =0 ; } }spin_unlock_bh (&card->ip_lock); +return rc; }/*
@@ -619,7 +623,7 @@ int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto, const u8 *addr) {struct qeth_ipaddr *ipaddr; -int rc =0 ; +int rc; ipaddr =qeth_l3_get_addr_buffer (proto);if (ipaddr) {
@@ -643,7 +647,7 @@ int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,if (qeth_l3_ip_from_hash (card, ipaddr)) rc = -EEXIST ;else -qeth_l3_add_ip (card, ipaddr); + rc =qeth_l3_add_ip (card, ipaddr);spin_unlock_bh (&card->ip_lock);
@@ -652,10 +656,11 @@ int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto,return rc; } -void qeth_l3_del_vipa (struct qeth_card *card,enum qeth_prot_versions proto, -const u8 *addr) +int qeth_l3_del_vipa (struct qeth_card *card,enum qeth_prot_versions proto, +const u8 *addr) {struct qeth_ipaddr *ipaddr; +int rc; ipaddr =qeth_l3_get_addr_buffer (proto);if (ipaddr) {
@@ -670,13 +675,14 @@ void qeth_l3_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto, } ipaddr->type =QETH_IP_TYPE_VIPA ; }else -return ; +return -ENOMEM ;spin_lock_bh (&card->ip_lock); -qeth_l3_delete_ip (card, ipaddr); + rc =qeth_l3_delete_ip (card, ipaddr);spin_unlock_bh (&card->ip_lock);kfree (ipaddr); +return rc; }/*
@@ -686,7 +692,7 @@ int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto, const u8 *addr) {struct qeth_ipaddr *ipaddr; -int rc =0 ; +int rc; ipaddr =qeth_l3_get_addr_buffer (proto);if (ipaddr) {
@@ -711,7 +717,7 @@ int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto,if (qeth_l3_ip_from_hash (card, ipaddr)) rc = -EEXIST ;else -qeth_l3_add_ip (card, ipaddr); + rc =qeth_l3_add_ip (card, ipaddr);spin_unlock_bh (&card->ip_lock);
@@ -720,10 +726,11 @@ int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto,return rc; } -void qeth_l3_del_rxip (struct qeth_card *card,enum qeth_prot_versions proto, -const u8 *addr) +int qeth_l3_del_rxip (struct qeth_card *card,enum qeth_prot_versions proto, +const u8 *addr) {struct qeth_ipaddr *ipaddr; +int rc; ipaddr =qeth_l3_get_addr_buffer (proto);if (ipaddr) {
@@ -738,13 +745,14 @@ void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto, } ipaddr->type =QETH_IP_TYPE_RXIP ; }else -return ; +return -ENOMEM ;spin_lock_bh (&card->ip_lock); -qeth_l3_delete_ip (card, ipaddr); + rc =qeth_l3_delete_ip (card, ipaddr);spin_unlock_bh (&card->ip_lock);kfree (ipaddr); +return rc; } static int qeth_l3_register_addr_entry(struct qeth_card *card,
drivers/s390/net/qeth_l3_sys.c +6 -6
@@ -274,7 +274,7 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,struct qeth_card *card =dev_get_drvdata (dev);struct qeth_ipaddr *addr;char *tmp; -int i; +int rc, i;if (!card)return -EINVAL ;
@@ -343,11 +343,11 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,return -ENOMEM ;spin_lock_bh (&card->ip_lock); -qeth_l3_add_ip (card, addr); + rc =qeth_l3_add_ip (card, addr);spin_unlock_bh (&card->ip_lock);kfree (addr); -return count; +return rc ? rc : count; } static DEVICE_ATTR(hsuid, 0644, qeth_l3_dev_hsuid_show,
@@ -585,7 +585,7 @@ static ssize_t qeth_l3_dev_ipato_del_store(const char *buf, size_t count,mutex_lock (&card->conf_mutex); rc =qeth_l3_parse_ipatoe (buf, proto, addr, &mask_bits);if (!rc) -qeth_l3_del_ipato_entry (card, proto, addr, mask_bits); + rc =qeth_l3_del_ipato_entry (card, proto, addr, mask_bits);mutex_unlock (&card->conf_mutex);return rc ? rc : count; }
@@ -796,7 +796,7 @@ static ssize_t qeth_l3_dev_vipa_del_store(const char *buf, size_t count,mutex_lock (&card->conf_mutex); rc =qeth_l3_parse_vipae (buf, proto, addr);if (!rc) -qeth_l3_del_vipa (card, proto, addr); + rc =qeth_l3_del_vipa (card, proto, addr);mutex_unlock (&card->conf_mutex);return rc ? rc : count; }
@@ -976,7 +976,7 @@ static ssize_t qeth_l3_dev_rxip_del_store(const char *buf, size_t count,mutex_lock (&card->conf_mutex); rc =qeth_l3_parse_rxipe (buf, proto, addr);if (!rc) -qeth_l3_del_rxip (card, proto, addr); + rc =qeth_l3_del_rxip (card, proto, addr);mutex_unlock (&card->conf_mutex);return rc ? rc : count; }
Signature · 1 line
2.13.5
PATCH 2/4 s390/qeth: use common helper to display rxip/vipa
In reply to Julian WiedmannBy parameterising the address type, we need just one helper that walks the IP table and builds up the response string.
--- drivers/s390/net/qeth_l3_sys.c | 90 +++++++++++------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-)
drivers/s390/net/qeth_l3_sys.c +24 -66
@@ -705,22 +705,25 @@ static const struct attribute_group qeth_device_ipato_group = { .attrs = qeth_ipato_device_attrs, }; -static ssize_t qeth_l3_dev_vipa_add_show (char *buf,struct qeth_card *card, -enum qeth_prot_versions proto) +static ssize_t qeth_l3_dev_ip_add_show (struct device *dev,char *buf, +enum qeth_prot_versions proto, +enum qeth_ip_types type) { +struct qeth_card *card =dev_get_drvdata (dev);struct qeth_ipaddr *ipaddr;char addr_str[40 ];int str_len =0 ;int entry_len;/* length of 1 entry string, differs between v4 and v6 */ int i; +if (!card) +return -EINVAL ; + entry_len = (proto ==QETH_PROT_IPV4 )?12 :40 ; entry_len +=2 ;/* \n + terminator */ spin_lock_bh (&card->ip_lock);hash_for_each (card->ip_htable, i, ipaddr, hnode) { -if (ipaddr->proto != proto) -continue ; -if (ipaddr->type !=QETH_IP_TYPE_VIPA ) +if (ipaddr->proto != proto || ipaddr->type != type)continue ;/* String must not be longer than PAGE_SIZE. So we check if * string length gets near PAGE_SIZE. Then we can savely display
@@ -739,14 +742,11 @@ static ssize_t qeth_l3_dev_vipa_add_show(char *buf, struct qeth_card *card, }static ssize_t qeth_l3_dev_vipa_add4_show (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr, +char *buf) { -struct qeth_card *card =dev_get_drvdata (dev); - -if (!card) -return -EINVAL ; - -return qeth_l3_dev_vipa_add_show (buf, card,QETH_PROT_IPV4 ); +return qeth_l3_dev_ip_add_show (dev, buf,QETH_PROT_IPV4 , +QETH_IP_TYPE_VIPA ); } static int qeth_l3_parse_vipae(const char *buf, enum qeth_prot_versions proto,
@@ -816,14 +816,11 @@ static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL, qeth_l3_dev_vipa_del4_store);static ssize_t qeth_l3_dev_vipa_add6_show (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr, +char *buf) { -struct qeth_card *card =dev_get_drvdata (dev); - -if (!card) -return -EINVAL ; - -return qeth_l3_dev_vipa_add_show (buf, card,QETH_PROT_IPV6 ); +return qeth_l3_dev_ip_add_show (dev, buf,QETH_PROT_IPV6 , +QETH_IP_TYPE_VIPA ); } static ssize_t qeth_l3_dev_vipa_add6_store(struct device *dev,
@@ -868,48 +865,12 @@ static const struct attribute_group qeth_device_vipa_group = { .attrs = qeth_vipa_device_attrs, }; -static ssize_t qeth_l3_dev_rxip_add_show (char *buf,struct qeth_card *card, -enum qeth_prot_versions proto) -{ -struct qeth_ipaddr *ipaddr; -char addr_str[40 ]; -int str_len =0 ; -int entry_len;/* length of 1 entry string, differs between v4 and v6 */ -int i; - - entry_len = (proto ==QETH_PROT_IPV4 )?12 :40 ; - entry_len +=2 ;/* \n + terminator */ -spin_lock_bh (&card->ip_lock); -hash_for_each (card->ip_htable, i, ipaddr, hnode) { -if (ipaddr->proto != proto) -continue ; -if (ipaddr->type !=QETH_IP_TYPE_RXIP ) -continue ; -/* String must not be longer than PAGE_SIZE. So we check if -* string length gets near PAGE_SIZE. Then we can savely display -* the next IPv6 address (worst case, compared to IPv4) */ -if ((PAGE_SIZE - str_len) <= entry_len) -break ; -qeth_l3_ipaddr_to_string (proto, (const u8 *)&ipaddr->u, - addr_str); - str_len +=snprintf (buf + str_len,PAGE_SIZE - str_len,"%s\n" , - addr_str); - } -spin_unlock_bh (&card->ip_lock); - str_len +=snprintf (buf + str_len,PAGE_SIZE - str_len,"\n" ); - -return str_len; -} -static ssize_t qeth_l3_dev_rxip_add4_show (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr, +char *buf) { -struct qeth_card *card =dev_get_drvdata (dev); - -if (!card) -return -EINVAL ; - -return qeth_l3_dev_rxip_add_show (buf, card,QETH_PROT_IPV4 ); +return qeth_l3_dev_ip_add_show (dev, buf,QETH_PROT_IPV4 , +QETH_IP_TYPE_RXIP ); } static int qeth_l3_parse_rxipe(const char *buf, enum qeth_prot_versions proto,
@@ -996,14 +957,11 @@ static QETH_DEVICE_ATTR(rxip_del4, del4, 0200, NULL, qeth_l3_dev_rxip_del4_store);static ssize_t qeth_l3_dev_rxip_add6_show (struct device *dev, -struct device_attribute *attr,char *buf) +struct device_attribute *attr, +char *buf) { -struct qeth_card *card =dev_get_drvdata (dev); - -if (!card) -return -EINVAL ; - -return qeth_l3_dev_rxip_add_show (buf, card,QETH_PROT_IPV6 ); +return qeth_l3_dev_ip_add_show (dev, buf,QETH_PROT_IPV6 , +QETH_IP_TYPE_RXIP ); } static ssize_t qeth_l3_dev_rxip_add6_store(struct device *dev,
Signature · 1 line
2.13.5
PATCH 3/4 s390/diag: add diag26c support for VNIC info
In reply to Julian WiedmannWith subcode 0x24, diag26c returns all sorts of VNIC-related information.
--- arch/s390/include/asm/diag.h | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)
arch/s390/include/asm/diag.h +43 -1
@@ -229,13 +229,55 @@ struct diag204_x_phys_block { } __packed;enum diag26c_sc { +DIAG26C_PORT_VNIC =0x00000024 ,DIAG26C_MAC_SERVICES =0x00000030 };enum diag26c_version { -DIAG26C_VERSION2 =0x00000002 /* z/VM 5.4.0 */ +DIAG26C_VERSION2 =0x00000002 ,/* z/VM 5.4.0 */ +DIAG26C_VERSION6_VM65918 =0x00020006 /* z/VM 6.4.0 + VM65918 */ }; +#define DIAG26C_VNIC_INFO 0x0002 +struct diag26c_vnic_req { +u32 resp_buf_len; +u32 resp_version; +u16 req_format; +u16 vlan_id; +u64 sys_name; +u8 res[2 ]; +u16 devno; +} __packed__aligned(8) ; + +#define VNIC_INFO_PROT_L3 1 +#define VNIC_INFO_PROT_L2 2 +/* Note: this is the bare minimum, use it for uninitialized VNICs only. */ +struct diag26c_vnic_resp { +u32 version; +u32 entry_cnt; +/* VNIC info: */ +u32 next_entry; +u64 owner; +u16 devno; +u8 status; +u8 type; +u64 lan_owner; +u64 lan_name; +u64 port_name; +u8 port_type; +u8 ext_status:6 ; +u8 protocol:2 ; +u16 base_devno; +u32 port_num; +u32 ifindex; +u32 maxinfo; +u32 dev_count; +/* 3x device info: */ +u8 dev_info1[28 ]; +u8 dev_info2[28 ]; +u8 dev_info3[28 ]; +} __packed__aligned(8) ; +#define DIAG26C_GET_MAC 0x0000struct diag26c_mac_req {u32 resp_buf_len;
Signature · 1 line
2.13.5
PATCH 4/4 s390/qeth: support early setup for z/VM NICs
In reply to Julian WiedmannThe transport mode that a z/VM NIC is configured in, must match the hypervisor-internal network which the NIC is coupled to.
To get this right automatically, have qeth issue a diag26c hypervisor call that provides all sorts of information for a specific VNIC. With z/VM update VM65918, this also includes the VNIC's required transport mode.
--- drivers/s390/net/qeth_core_main.c | 86 +++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 9 deletions(-)
drivers/s390/net/qeth_core_main.c +77 -9
@@ -36,6 +36,7 @@#include <asm/diag.h> #include <asm/cio.h> #include <asm/ccwdev.h> +#include <asm/cpcmd.h> #include "qeth_core.h"
@@ -1715,23 +1716,87 @@ static void qeth_configure_unitaddr(struct qeth_card *card, char *prcd) (prcd[0x11] == _ascebc['M'])); } +static enum qeth_discipline_id qeth_vm_detect_layer (struct qeth_card *card) +{ +enum qeth_discipline_id disc =QETH_DISCIPLINE_UNDETERMINED ; +struct diag26c_vnic_resp *response =NULL ; +struct diag26c_vnic_req *request =NULL ; +struct ccw_dev_id id; +char userid[80 ]; +int rc =0 ; + +QETH_DBF_TEXT (SETUP ,2 ,"vmlayer" ); + +cpcmd ("QUERY USERID" , userid,sizeof (userid), &rc); +if (rc) + goto out; + + request =kzalloc (sizeof (*request),GFP_KERNEL |GFP_DMA ); + response =kzalloc (sizeof (*response),GFP_KERNEL |GFP_DMA ); +if (!request || !response) { + rc = -ENOMEM ; + goto out; + } + +ccw_device_get_id (CARD_RDEV (card), &id); + request->resp_buf_len =sizeof (*response); + request->resp_version =DIAG26C_VERSION6_VM65918 ; + request->req_format =DIAG26C_VNIC_INFO ; +ASCEBC (userid,8 ); +memcpy (&request->sys_name, userid,8 ); + request->devno = id.devno; + +QETH_DBF_HEX (CTRL ,2 , request,sizeof (*request)); + rc =diag26c (request, response,DIAG26C_PORT_VNIC ); +QETH_DBF_HEX (CTRL ,2 , request,sizeof (*request)); +if (rc) + goto out; +QETH_DBF_HEX (CTRL ,2 , response,sizeof (*response)); + +if (request->resp_buf_len <sizeof (*response) || + response->version != request->resp_version) { + rc = -EIO ; + goto out; + } + +if (response->protocol ==VNIC_INFO_PROT_L2 ) + disc =QETH_DISCIPLINE_LAYER2 ; +else if (response->protocol ==VNIC_INFO_PROT_L3 ) + disc =QETH_DISCIPLINE_LAYER3 ; + +out: +kfree (response); +kfree (request); +if (rc) +QETH_DBF_TEXT_ (SETUP ,2 ,"err%x" , rc); +return disc; +} +/* Determine whether the device requires a specific layer discipline */ static enum qeth_discipline_id qeth_enforce_discipline (struct qeth_card *card) { +enum qeth_discipline_id disc =QETH_DISCIPLINE_UNDETERMINED ; +if (card->info.type ==QETH_CARD_TYPE_OSM || - card->info.type ==QETH_CARD_TYPE_OSN ) { + card->info.type ==QETH_CARD_TYPE_OSN ) + disc =QETH_DISCIPLINE_LAYER2 ; +else if (card->info.guestlan) + disc = (card->info.type ==QETH_CARD_TYPE_IQD ) ? +QETH_DISCIPLINE_LAYER3 : +qeth_vm_detect_layer (card); + +switch (disc) { +case QETH_DISCIPLINE_LAYER2 :QETH_DBF_TEXT (SETUP ,3 ,"force l2" ); -return QETH_DISCIPLINE_LAYER2 ; - } - -/* virtual HiperSocket is L3 only: */ -if (card->info.guestlan && card->info.type ==QETH_CARD_TYPE_IQD ) { +break ; +case QETH_DISCIPLINE_LAYER3 :QETH_DBF_TEXT (SETUP ,3 ,"force l3" ); -return QETH_DISCIPLINE_LAYER3 ; +break ; +default : +QETH_DBF_TEXT (SETUP ,3 ,"force no" ); } -QETH_DBF_TEXT (SETUP ,3 ,"force no" ); -return QETH_DISCIPLINE_UNDETERMINED ; +return disc; }static void qeth_configure_blkt_default (struct qeth_card *card,char *prcd)
@@ -4786,9 +4851,12 @@ int qeth_vm_request_mac(struct qeth_card *card) request->op_code =DIAG26C_GET_MAC ; request->devno = id.devno; +QETH_DBF_HEX (CTRL ,2 , request,sizeof (*request)); rc =diag26c (request, response,DIAG26C_MAC_SERVICES ); +QETH_DBF_HEX (CTRL ,2 , request,sizeof (*request));if (rc) goto out; +QETH_DBF_HEX (CTRL ,2 , response,sizeof (*response));if (request->resp_buf_len <sizeof (*response) || response->version != request->resp_version) {
Signature · 1 line
2.13.5
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Wed, 27 Dec 2017 17:44:27 +0100
Quoted 4 lines
please apply some post-christmas leftovers for 4.16.
Two patches to improve IP address management on L3, and two that add support to auto-config the transport mode on z/VM VNICs. Note that one patch in the series touchesarch/s390(acked by Martin).
Series applied, thanks Julian.