s390/qeth: updates 2020-09-23
Subsystems (4)
cover s390/qeth: updates 2020-09-23
Hi Dave & Jakub,
please apply the following patch series for qeth to netdev's net-next tree.
This brings all sorts of cleanups. Highlights are more code sharing in the init/teardown paths, and more fine-grained rollback on errors during initialization (instead of a full-blown teardown).
Thanks,
Julian
Julian Wiedmann (9):
s390/qeth: don't init refcount twice for mcast IPs s390/qeth: relax locking for ipato config data s390/qeth: clean up string ops in qeth_l3_parse_ipatoe() s390/qeth: replace deprecated simple_stroul() s390/qeth: tighten ucast IP locking
s390/qeth: cancel cmds earlier during teardown s390/qeth: consolidate online code
s390/qeth: consolidate teardown code
s390/qeth: remove forward declarations in L2 code
drivers/s390/net/qeth_core.h | 22 +- drivers/s390/net/qeth_core_main.c | 71 +++-- drivers/s390/net/qeth_core_sys.c | 65 ++--- drivers/s390/net/qeth_l2.h | 7 + drivers/s390/net/qeth_l2_main.c | 412 +++++++++++++----------------- drivers/s390/net/qeth_l3.h | 4 +- drivers/s390/net/qeth_l3_main.c | 88 ++----- drivers/s390/net/qeth_l3_sys.c | 64 ++--- 8 files changed, 338 insertions(+), 395 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/9 s390/qeth: don't init refcount twice for mcast IPs
mcast IP objects are allocated within qeth_l3_add_mcast_rtnl(), with .ref_counter already set to 1 via qeth_l3_init_ipaddr().
--- drivers/s390/net/qeth_l3_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/s390/net/qeth_l3_main.c +0 -1
@@ -1235,7 +1235,6 @@ static void qeth_l3_rx_mode_work(struct work_struct *work)kfree (addr);break ; } - addr->ref_counter =1 ; fallthrough;default :/* for next call to set_rx_mode(): */
Signature · 1 line
2.17.1
PATCH 2/9 s390/qeth: relax locking for ipato config data
In reply to Julian Wiedmanncard->ipato is currently protected by the conf_mutex. But most users also hold the ip_lock - in particular qeth_l3_add_ip().
So slightly expand the sections under ip_lock in a few places (to effectively cover a few error & no-op cases), and then drop the conf_mutex where it's no longer needed.
--- drivers/s390/net/qeth_core.h | 7 +++++-- drivers/s390/net/qeth_l3_main.c | 4 ---- drivers/s390/net/qeth_l3_sys.c | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-)
drivers/s390/net/qeth_core.h +5 -2
@@ -814,12 +814,16 @@ struct qeth_card {struct workqueue_struct *event_wq;struct workqueue_struct *cmd_wq;wait_queue_head_t wait_q; + +struct mutex ip_lock; +/* protected by ip_lock: */ DECLARE_HASHTABLE (ip_htable,4 ); +struct qeth_ipato ipato; +DECLARE_HASHTABLE (local_addrs4,4 );DECLARE_HASHTABLE (local_addrs6,4 );spinlock_t local_addrs4_lock;spinlock_t local_addrs6_lock; -struct mutex ip_lock;DECLARE_HASHTABLE (rx_mode_addrs,4 );struct work_struct rx_mode_work;struct work_struct kernel_thread_starter;
@@ -827,7 +831,6 @@ struct qeth_card {unsigned long thread_start_mask;unsigned long thread_allowed_mask;unsigned long thread_running_mask; -struct qeth_ipato ipato;struct list_head cmd_waiter_list;/* QDIO buffer handling */ struct qeth_qdio_info qdio;
drivers/s390/net/qeth_l3_main.c +0 -4
@@ -536,7 +536,6 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card,QETH_CARD_TEXT (card,2 ,"addipato" ); -mutex_lock (&card->conf_mutex);mutex_lock (&card->ip_lock);list_for_each_entry (ipatoe, &card->ipato.entries, entry) {
@@ -556,7 +555,6 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card, }mutex_unlock (&card->ip_lock); -mutex_unlock (&card->conf_mutex);return rc; }
@@ -570,7 +568,6 @@ int qeth_l3_del_ipato_entry(struct qeth_card *card,QETH_CARD_TEXT (card,2 ,"delipato" ); -mutex_lock (&card->conf_mutex);mutex_lock (&card->ip_lock);list_for_each_entry_safe (ipatoe, tmp, &card->ipato.entries, entry) {
@@ -587,7 +584,6 @@ int qeth_l3_del_ipato_entry(struct qeth_card *card, }mutex_unlock (&card->ip_lock); -mutex_unlock (&card->conf_mutex);return rc; }
drivers/s390/net/qeth_l3_sys.c +11 -11
@@ -301,19 +301,21 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, goto out; } +mutex_lock (&card->ip_lock);if (sysfs_streq (buf,"toggle" )) { enable = !card->ipato.enabled; }else if (kstrtobool (buf, &enable)) { rc = -EINVAL ; - goto out; + goto unlock_ip; }if (card->ipato.enabled != enable) { card->ipato.enabled = enable; -mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -mutex_unlock (&card->ip_lock); } + +unlock_ip: +mutex_unlock (&card->ip_lock); out:mutex_unlock (&card->conf_mutex);return rc ? rc : count;
@@ -339,7 +341,7 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,bool invert;int rc =0 ; -mutex_lock (&card->conf_mutex); +mutex_lock (&card->ip_lock);if (sysfs_streq (buf,"toggle" )) { invert = !card->ipato.invert4; }else if (kstrtobool (buf, &invert)) {
@@ -349,12 +351,11 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,if (card->ipato.invert4 != invert) { card->ipato.invert4 = invert; -mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -mutex_unlock (&card->ip_lock); } + out: -mutex_unlock (&card->conf_mutex); +mutex_unlock (&card->ip_lock);return rc ? rc : count; }
@@ -510,7 +511,7 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,bool invert;int rc =0 ; -mutex_lock (&card->conf_mutex); +mutex_lock (&card->ip_lock);if (sysfs_streq (buf,"toggle" )) { invert = !card->ipato.invert6; }else if (kstrtobool (buf, &invert)) {
@@ -520,12 +521,11 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,if (card->ipato.invert6 != invert) { card->ipato.invert6 = invert; -mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -mutex_unlock (&card->ip_lock); } + out: -mutex_unlock (&card->conf_mutex); +mutex_unlock (&card->ip_lock);return rc ? rc : count; }
Signature · 1 line
2.17.1
PATCH 3/9 s390/qeth: clean up string ops in qeth_l3_parse_ipatoe()
In reply to Julian WiedmannIndicate the max number of to-be-parsed characters, and avoid copying the address sub-string.
--- drivers/s390/net/qeth_l3_sys.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/s390/net/qeth_l3_sys.c +14 -13
@@ -409,21 +409,22 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,static int qeth_l3_parse_ipatoe (const char *buf,enum qeth_prot_versions proto,u8 *addr,int *mask_bits) { -const char *start, *end; -char *tmp; -char buffer[40 ] = {0 , }; +const char *start; +char *sep, *tmp; +int rc; - start = buf; -/* get address string */ - end =strchr (start,'/' ); -if (!end || (end - start >=40 )) { +/* Expected input pattern: %addr/%mask */ + sep =strnchr (buf,40 ,'/' ); +if (!sep)return -EINVAL ; - } -strncpy (buffer, start, end - start); -if (qeth_l3_string_to_ipaddr (buffer, proto, addr)) { -return -EINVAL ; - } - start = end +1 ; + +/* Terminate the %addr sub-string, and parse it: */ + *sep ='\0' ; + rc =qeth_l3_string_to_ipaddr (buf, proto, addr); +if (rc) +return rc; + + start = sep +1 ; *mask_bits =simple_strtoul (start, &tmp,10 ); if (!strlen(start) || (tmp == start) ||
Signature · 1 line
2.17.1
RE: [PATCH net-next 3/9] s390/qeth: clean up string ops in qeth_l3_parse_ipatoe()
From: Julian Wiedmann
Quoted 32 lines
Sent: 23 September 2020 09:37
Indicate the max number of to-be-parsed characters, and avoid copying the address sub-string.
Signed-off-by Julian Wiedmann <[email protected]>--- drivers/s390/net/qeth_l3_sys.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)drivers/s390/net/qeth_l3_sys.c +6
-7@@ -409,21 +409,22 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,static int qeth_l3_parse_ipatoe (const char *buf,enum qeth_prot_versions proto,u8 *addr,int *mask_bits) { -const char *start, *end; -char *tmp; -char buffer[40 ] = {0 , }; +const char *start; +char *sep, *tmp; +int rc; - start = buf; -/* get address string */ - end =strchr (start,'/' ); -if (!end || (end - start >=40 )) { +/* Expected input pattern: %addr/%mask */ + sep =strnchr (buf,40 ,'/' ); +if (!sep)
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 422
Quoted 10 lines
drivers/s390/net/qeth_l3_sys.c +3
-6return -EINVAL ; - } -strncpy (buffer, start, end - start); -if (qeth_l3_string_to_ipaddr (buffer, proto, addr)) { -return -EINVAL ; - } - start = end +1 ; + +/* Terminate the %addr sub-string, and parse it: */ + *sep ='\0' ;
Is it valid to write into the input buffer here?
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 428
Quoted 6 lines
drivers/s390/net/qeth_l3_sys.c +5
-0+ rc =qeth_l3_string_to_ipaddr (buf, proto, addr); +if (rc) +return rc; + + start = sep +1 ; *mask_bits =simple_strtoul (start, &tmp,10 );
The use of strnchr() rather implies that the input buffer may not be '\0' terminated.
If that is true then you've just run off the end of the input buffer.
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 430
Quoted 2 lines
drivers/s390/net/qeth_l3_sys.c +0
-0if (!strlen(start) || (tmp == start) ||
Hmmm... delete the strlen() clause.
It ought to test start[0], but the 'tmp == start' test covers that case.
I don't understand why simple_strtoul() is deprecated. I don't recall any of the replacements returning the address of the terminating character.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Re: [PATCH net-next 3/9] s390/qeth: clean up string ops in qeth_l3_parse_ipatoe()
Quoted 37 lines · David Laight
From: Julian Wiedmann
Quoted 36 lines
Sent: 23 September 2020 09:37
Indicate the max number of to-be-parsed characters, and avoid copying the address sub-string.
Signed-off-by Julian Wiedmann <[email protected]>--- drivers/s390/net/qeth_l3_sys.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)drivers/s390/net/qeth_l3_sys.c +6
-10@@ -409,21 +409,22 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,static int qeth_l3_parse_ipatoe (const char *buf,enum qeth_prot_versions proto,u8 *addr,int *mask_bits) { -const char *start, *end; -char *tmp; -char buffer[40 ] = {0 , }; +const char *start; +char *sep, *tmp; +int rc; - start = buf; -/* get address string */ - end =strchr (start,'/' ); -if (!end || (end - start >=40 )) { +/* Expected input pattern: %addr/%mask */ + sep =strnchr (buf,40 ,'/' ); +if (!sep)return -EINVAL ; - } -strncpy (buffer, start, end - start); -if (qeth_l3_string_to_ipaddr (buffer, proto, addr)) {
Quoted 9 lines
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 422
Quoted 6 lines
drivers/s390/net/qeth_l3_sys.c +3
-3-return -EINVAL ; - } - start = end +1 ; + +/* Terminate the %addr sub-string, and parse it: */ + *sep ='\0' ;Is it valid to write into the input buffer here?
It's a private buffer that was handed to us by the kernfs write code.
Quoted 9 lines
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 428
Quoted 6 lines
drivers/s390/net/qeth_l3_sys.c +5
-0+ rc =qeth_l3_string_to_ipaddr (buf, proto, addr); +if (rc) +return rc; + + start = sep +1 ; *mask_bits =simple_strtoul (start, &tmp,10 );The use of
strnchr()rather implies that the input buffer may not be '\0' terminated.
It's a kernfs write buffer, so guaranteed to be terminated.
Quoted 10 lines
If that is true then you've just run off the end of the input buffer.
drivers/s390/net/qeth_l3_sys.c static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, · line 430
Quoted 2 lines
drivers/s390/net/qeth_l3_sys.c +0
-0if (!strlen(start) || (tmp == start) ||Hmmm... delete the
strlen()clause.
It ought to test start[0], but the 'tmp == start' test covers that case.
See the next patch in this series, all this goes away.
Quoted 10 lines
I don't understand why
simple_strtoul()is deprecated. I don't recall any of the replacements returning the address of the terminating character.David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
b
PATCH 4/9 s390/qeth: replace deprecated simple_stroul()
In reply to Julian WiedmannConvert the remaining occurences in sysfs code to kstrtouint().
While at it move some input parsing out of locked sections, replace an open-coded clamp() and remove some unnecessary run-time checks for ipatoe->mask_bits that are already enforced when creating the object.
--- drivers/s390/net/qeth_core.h | 4 +- drivers/s390/net/qeth_core_sys.c | 65 +++++++++++++++++--------------- drivers/s390/net/qeth_l3.h | 4 +- drivers/s390/net/qeth_l3_main.c | 8 ++-- drivers/s390/net/qeth_l3_sys.c | 21 +++++------ 5 files changed, 51 insertions(+), 51 deletions(-)
drivers/s390/net/qeth_core.h +2 -2
@@ -195,8 +195,8 @@ struct qeth_vnicc_info {#define QETH_IN_BUF_SIZE_DEFAULT 65536#define QETH_IN_BUF_COUNT_DEFAULT 64#define QETH_IN_BUF_COUNT_HSDEFAULT 128 -#define QETH_IN_BUF_COUNT_MIN 8 -#define QETH_IN_BUF_COUNT_MAX 128 +#define QETH_IN_BUF_COUNT_MIN 8U +#define QETH_IN_BUF_COUNT_MAX 128U#define QETH_MAX_BUFFER_ELEMENTS (card) ((card)->qdio.in_buf_size >> 12)#define QETH_IN_BUF_REQUEUE_THRESHOLD (card) \ ((card)->qdio.in_buf_pool.buf_count / 2)
drivers/s390/net/qeth_core_sys.c +34 -31
119 lines not on this page · raw message
drivers/s390/net/qeth_l3.h +2 -2
@@ -96,7 +96,7 @@ struct qeth_ipato_entry {struct list_head entry;enum qeth_prot_versions proto;char addr[16 ]; -int mask_bits; +unsigned int mask_bits; };extern const struct attribute_group *qeth_l3_attr_groups[];
@@ -110,7 +110,7 @@ int qeth_l3_setrouting_v6(struct qeth_card *);int qeth_l3_add_ipato_entry (struct qeth_card *,struct qeth_ipato_entry *);int qeth_l3_del_ipato_entry (struct qeth_card *card,enum qeth_prot_versions proto,u8 *addr, -int mask_bits); +unsigned int mask_bits);void qeth_l3_update_ipato (struct qeth_card *card);int qeth_l3_modify_hsuid (struct qeth_card *card,bool add); int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,
drivers/s390/net/qeth_l3_main.c +3 -5
@@ -105,11 +105,9 @@ static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card, (ipatoe->proto ==QETH_PROT_IPV4 ) ? 4 : 16);if (addr->proto ==QETH_PROT_IPV4 ) - rc = !memcmp (addr_bits, ipatoe_bits, -min (32 , ipatoe->mask_bits)); + rc = !memcmp (addr_bits, ipatoe_bits, ipatoe->mask_bits);else - rc = !memcmp (addr_bits, ipatoe_bits, -min (128 , ipatoe->mask_bits)); + rc = !memcmp (addr_bits, ipatoe_bits, ipatoe->mask_bits);if (rc)break ; }
@@ -561,7 +559,7 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card,int qeth_l3_del_ipato_entry (struct qeth_card *card,enum qeth_prot_versions proto,u8 *addr, -int mask_bits) +unsigned int mask_bits) {struct qeth_ipato_entry *ipatoe, *tmp;int rc = -ENOENT ;
drivers/s390/net/qeth_l3_sys.c +10 -11
@@ -407,10 +407,9 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, }static int qeth_l3_parse_ipatoe (const char *buf,enum qeth_prot_versions proto, -u8 *addr,int *mask_bits) +u8 *addr,unsigned int *mask_bits) { -const char *start; -char *sep, *tmp; +char *sep;int rc;/* Expected input pattern: %addr/%mask */
@@ -424,13 +423,13 @@ static int qeth_l3_parse_ipatoe(const char *buf, enum qeth_prot_versions proto,if (rc)return rc; - start = sep +1 ; - *mask_bits =simple_strtoul (start, &tmp,10 ); -if (!strlen (start) || - (tmp == start) || - (*mask_bits > ((proto ==QETH_PROT_IPV4 ) ?32 :128 ))) { + rc =kstrtouint (sep +1 ,10 , mask_bits); +if (rc) +return rc; + +if (*mask_bits > ((proto ==QETH_PROT_IPV4 ) ?32 :128 ))return -EINVAL ; - } +return 0 ; }
@@ -438,8 +437,8 @@ static ssize_t qeth_l3_dev_ipato_add_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { struct qeth_ipato_entry *ipatoe; +unsigned int mask_bits;u8 addr[16 ]; -int mask_bits;int rc =0 ; rc =qeth_l3_parse_ipatoe (buf, proto, addr, &mask_bits);
@@ -476,8 +475,8 @@ static QETH_DEVICE_ATTR(ipato_add4, add4, 0644,static ssize_t qeth_l3_dev_ipato_del_store (const char *buf,size_t count,struct qeth_card *card,enum qeth_prot_versions proto) { +unsigned int mask_bits;u8 addr[16 ]; -int mask_bits;int rc =0 ; rc =qeth_l3_parse_ipatoe (buf, proto, addr, &mask_bits);
Signature · 1 line
2.17.1
PATCH 5/9 s390/qeth: tighten ucast IP locking
In reply to Julian WiedmannThe programming of ucast IPs via qeth_l3_modify_ip() is driven independently from any of our typical locking mechanisms (eg. detaching the netdevice, or holding the conf_mutex).
So when we inspect the card state to check whether the required cmd IO should be deferred, there is no protection against concurrent state changes.
But by slightly re-ordering the teardown sequence, we can rely on the ip_lock to sufficiently serialize things:
1. when running concurrently to qeth_l3_set_online(), any instance of qeth_l3_modify_ip() that aquires the ip_lock _after_ qeth_l3_recover_ip() will observe the state as CARD_STATE_SOFTSETUP and not defer the IO.
2. when running concurrently to qeth_l3_set_offline(), any instance of qeth_l3_modify_ip() that aquires the ip_lock _after_ qeth_l3_clear_ip_htable() will observe the state as CARD_STATE_DOWN and defer the IO.
These guarantees in mind, we can now drop the conf_mutex from the qeth_l3_modify_rxip_vipa() wrapper.
--- drivers/s390/net/qeth_l3_main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/s390/net/qeth_l3_main.c +2 -7
@@ -591,7 +591,6 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip, enum qeth_prot_versions proto) {struct qeth_ipaddr addr; -int rc;qeth_l3_init_ipaddr (&addr, type, proto);if (proto ==QETH_PROT_IPV4 )
@@ -599,11 +598,7 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,else memcpy (&addr.u.a6.addr, ip,16 ); -mutex_lock (&card->conf_mutex); - rc =qeth_l3_modify_ip (card, &addr, add); -mutex_unlock (&card->conf_mutex); - -return rc; +return qeth_l3_modify_ip (card, &addr, add); }int qeth_l3_modify_hsuid (struct qeth_card *card,bool add)
@@ -1161,9 +1156,9 @@ static void qeth_l3_stop_card(struct qeth_card *card)qeth_diags_trace (card,QETH_DIAGS_CMD_TRACE_DISABLE );if (card->state ==CARD_STATE_SOFTSETUP ) { + card->state =CARD_STATE_DOWN ;qeth_l3_clear_ip_htable (card,1 );qeth_clear_ipacmd_list (card); - card->state =CARD_STATE_DOWN ; }qeth_qdio_clear_card (card,0 );
Signature · 1 line
2.17.1
PATCH 6/9 s390/qeth: cancel cmds earlier during teardown
In reply to Julian WiedmannOriginators of cmd IO typically hold the rtnl or conf_mutex to protect against a concurrent teardown.
Since qeth_set_offline() already holds the conf_mutex, the main reason why we still care about cancelling pending cmds is so that they release the rtnl when we need it ourselves.
So move this step a little earlier into the teardown sequence.
--- drivers/s390/net/qeth_core.h | 1 - drivers/s390/net/qeth_core_main.c | 6 ++++-- drivers/s390/net/qeth_l2_main.c | 4 +--- drivers/s390/net/qeth_l3_main.c | 1 - 4 files changed, 5 insertions(+), 7 deletions(-)
drivers/s390/net/qeth_core.h +0 -1
@@ -1067,7 +1067,6 @@ void qeth_put_cmd(struct qeth_cmd_buffer *iob);int qeth_schedule_recovery (struct qeth_card *card);void qeth_flush_local_addrs (struct qeth_card *card);int qeth_poll (struct napi_struct *napi,int budget); -void qeth_clear_ipacmd_list (struct qeth_card *);int qeth_qdio_clear_card (struct qeth_card *,int );void qeth_clear_working_pool_list (struct qeth_card *);void qeth_drain_output_queues (struct qeth_card *card);
drivers/s390/net/qeth_core_main.c +4 -2
@@ -965,7 +965,7 @@ static struct qeth_ipa_cmd *qeth_check_ipa_data(struct qeth_card *card, } } -void qeth_clear_ipacmd_list (struct qeth_card *card) +static void qeth_clear_ipacmd_list (struct qeth_card *card) {struct qeth_cmd_buffer *iob;unsigned long flags;
@@ -977,7 +977,6 @@ void qeth_clear_ipacmd_list(struct qeth_card *card)qeth_notify_cmd (iob, -ECANCELED );spin_unlock_irqrestore (&card->lock, flags); } -EXPORT_SYMBOL_GPL (qeth_clear_ipacmd_list);static int qeth_check_idx_response (struct qeth_card *card,unsigned char *buffer)
@@ -5334,6 +5333,9 @@ int qeth_set_offline(struct qeth_card *card, bool resetting) card->info.hwtrap =1 ; } +/* cancel any stalled cmd that might block the rtnl: */ +qeth_clear_ipacmd_list (card); +rtnl_lock (); card->info.open_when_online = card->dev->flags &IFF_UP ;dev_close (card->dev);
drivers/s390/net/qeth_l2_main.c +1 -3
@@ -315,10 +315,8 @@ static void qeth_l2_stop_card(struct qeth_card *card)cancel_work_sync (&card->rx_mode_work);qeth_l2_drain_rx_mode_cache (card); -if (card->state ==CARD_STATE_SOFTSETUP ) { -qeth_clear_ipacmd_list (card); +if (card->state ==CARD_STATE_SOFTSETUP ) card->state =CARD_STATE_DOWN ; - }qeth_qdio_clear_card (card,0 );qeth_drain_output_queues (card);
drivers/s390/net/qeth_l3_main.c +0 -1
@@ -1158,7 +1158,6 @@ static void qeth_l3_stop_card(struct qeth_card *card)if (card->state ==CARD_STATE_SOFTSETUP ) { card->state =CARD_STATE_DOWN ;qeth_l3_clear_ip_htable (card,1 ); -qeth_clear_ipacmd_list (card); }qeth_qdio_clear_card (card,0 );
Signature · 1 line
2.17.1
PATCH 7/9 s390/qeth: consolidate online code
In reply to Julian WiedmannMove duplicated code from the disciplines into the core path.
--- drivers/s390/net/qeth_core.h | 6 +---- drivers/s390/net/qeth_core_main.c | 41 ++++++++++++++++++++++++------- drivers/s390/net/qeth_l2_main.c | 20 +-------------- drivers/s390/net/qeth_l3_main.c | 21 ++-------------- 4 files changed, 36 insertions(+), 52 deletions(-)
drivers/s390/net/qeth_core.h +1 -5
@@ -753,7 +753,7 @@ struct qeth_discipline {const struct device_type *devtype;int (*setup) (struct ccwgroup_device *);void (*remove) (struct ccwgroup_device *); -int (*set_online)(struct qeth_card *card); +int (*set_online)(struct qeth_card *card,bool carrier_ok);void (*set_offline)(struct qeth_card *card);int (*do_ioctl)(struct net_device *dev,struct ifreq *rq,int cmd); int (*control_event_handler)(struct qeth_card *card,
@@ -1037,11 +1037,8 @@ struct net_device *qeth_clone_netdev(struct net_device *orig);struct qeth_card *qeth_get_card_by_busid (char *bus_id);void qeth_set_allowed_threads (struct qeth_card *,unsigned long ,int );int qeth_threads_running (struct qeth_card *,unsigned long ); -int qeth_core_hardsetup_card (struct qeth_card *card,bool *carrier_ok); -int qeth_stop_channel (struct qeth_channel *channel);int qeth_set_offline (struct qeth_card *card,bool resetting); -void qeth_print_status_message (struct qeth_card *); int qeth_send_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, int (*reply_cb) (struct qeth_card *, struct qeth_reply *, unsigned long),
@@ -1093,7 +1090,6 @@ int qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);void qeth_dbf_longtext (debug_info_t *id,int level,char *text, ...);int qeth_configure_cq (struct qeth_card *,enum qeth_cq );int qeth_hw_trap (struct qeth_card *,enum qeth_diags_trap_action ); -void qeth_trace_features (struct qeth_card *);int qeth_setassparms_cb (struct qeth_card *,struct qeth_reply *,unsigned long );int qeth_setup_netdev (struct qeth_card *card);int qeth_set_features (struct net_device *,netdev_features_t );
drivers/s390/net/qeth_core_main.c +32 -9
108 lines not on this page · raw message
drivers/s390/net/qeth_l2_main.c +1 -19
@@ -1138,19 +1138,10 @@ static void qeth_l2_enable_brport_features(struct qeth_card *card) } } -static int qeth_l2_set_online (struct qeth_card *card) +static int qeth_l2_set_online (struct qeth_card *card,bool carrier_ok) { -struct ccwgroup_device *gdev = card->gdev;struct net_device *dev = card->dev;int rc =0 ; -bool carrier_ok; - - rc =qeth_core_hardsetup_card (card, &carrier_ok); -if (rc) { -QETH_CARD_TEXT_ (card,2 ,"2err%04x" , rc); - rc = -ENODEV ; - goto out_remove; - }/* query before bridgeport_notification may be enabled */ qeth_l2_detect_dev2br_support (card);
@@ -1169,11 +1160,8 @@ static int qeth_l2_set_online(struct qeth_card *card)/* for the rx_bcast characteristic, init VNICC after setmac */ qeth_l2_vnicc_init (card); -qeth_trace_features (card);qeth_l2_trace_features (card); -qeth_print_status_message (card); -/* softsetup */ QETH_CARD_TEXT (card,2 ,"softsetp" );
@@ -1205,16 +1193,10 @@ static int qeth_l2_set_online(struct qeth_card *card) }rtnl_unlock (); } -/* let user_space know that device is online */ -kobject_uevent (&gdev->dev.kobj,KOBJ_CHANGE );return 0 ; out_remove:qeth_l2_stop_card (card); -qeth_stop_channel (&card->data); -qeth_stop_channel (&card->write); -qeth_stop_channel (&card->read); -qdio_free (CARD_DDEV (card));return rc; }
drivers/s390/net/qeth_l3_main.c +2 -19
@@ -2012,21 +2012,10 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)qeth_l3_clear_ipato_list (card); } -static int qeth_l3_set_online (struct qeth_card *card) +static int qeth_l3_set_online (struct qeth_card *card,bool carrier_ok) { -struct ccwgroup_device *gdev = card->gdev;struct net_device *dev = card->dev;int rc =0 ; -bool carrier_ok; - - rc =qeth_core_hardsetup_card (card, &carrier_ok); -if (rc) { -QETH_CARD_TEXT_ (card,2 ,"2err%04x" , rc); - rc = -ENODEV ; - goto out_remove; - } - -qeth_print_status_message (card);/* softsetup */ QETH_CARD_TEXT (card,2 ,"softsetp" );
@@ -2073,16 +2062,10 @@ static int qeth_l3_set_online(struct qeth_card *card) }rtnl_unlock (); } -qeth_trace_features (card); -/* let user_space know that device is online */ -kobject_uevent (&gdev->dev.kobj,KOBJ_CHANGE );return 0 ; + out_remove:qeth_l3_stop_card (card); -qeth_stop_channel (&card->data); -qeth_stop_channel (&card->write); -qeth_stop_channel (&card->read); -qdio_free (CARD_DDEV (card));return rc; }
Signature · 1 line
2.17.1
PATCH 8/9 s390/qeth: consolidate teardown code
In reply to Julian WiedmannClarify which discipline-specific steps are needed to roll back after error in qeth_l?_set_online(), and which are common to roll back from qeth_hardsetup_card().
Some steps (cancelling the RX modeset, draining the TX queues) are only necessary if the netdev was potentially UP before, so move them to the common qeth_set_offline().
--- drivers/s390/net/qeth_core.h | 4 --- drivers/s390/net/qeth_core_main.c | 24 ++++++++++----- drivers/s390/net/qeth_l2_main.c | 50 +++++++++++-------------------- drivers/s390/net/qeth_l3_main.c | 46 ++++++++++------------------ 4 files changed, 50 insertions(+), 74 deletions(-)
drivers/s390/net/qeth_core.h +0 -4
@@ -1062,11 +1062,7 @@ void qeth_notify_cmd(struct qeth_cmd_buffer *iob, int reason);void qeth_put_cmd (struct qeth_cmd_buffer *iob);int qeth_schedule_recovery (struct qeth_card *card); -void qeth_flush_local_addrs (struct qeth_card *card);int qeth_poll (struct napi_struct *napi,int budget); -int qeth_qdio_clear_card (struct qeth_card *,int ); -void qeth_clear_working_pool_list (struct qeth_card *); -void qeth_drain_output_queues (struct qeth_card *card);void qeth_setadp_promisc_mode (struct qeth_card *card,bool enable);int qeth_setadpparms_change_macaddr (struct qeth_card *);void qeth_tx_timeout (struct net_device *,unsigned int txqueue);
drivers/s390/net/qeth_core_main.c +16 -8
@@ -201,7 +201,7 @@ int qeth_threads_running(struct qeth_card *card, unsigned long threads) }EXPORT_SYMBOL_GPL (qeth_threads_running); -void qeth_clear_working_pool_list (struct qeth_card *card) +static void qeth_clear_working_pool_list (struct qeth_card *card) {struct qeth_buffer_pool_entry *pool_entry, *tmp;struct qeth_qdio_q *queue = card->qdio.in_q;
@@ -216,7 +216,6 @@ void qeth_clear_working_pool_list(struct qeth_card *card)for (i =0 ; i <ARRAY_SIZE (queue->bufs); i++) queue->bufs[i].pool_entry =NULL ; } -EXPORT_SYMBOL_GPL (qeth_clear_working_pool_list);static void qeth_free_pool_entry (struct qeth_buffer_pool_entry *entry) {
@@ -658,12 +657,11 @@ static void qeth_flush_local_addrs6(struct qeth_card *card)spin_unlock_irq (&card->local_addrs6_lock); } -void qeth_flush_local_addrs (struct qeth_card *card) +static void qeth_flush_local_addrs (struct qeth_card *card) {qeth_flush_local_addrs4 (card);qeth_flush_local_addrs6 (card); } -EXPORT_SYMBOL_GPL (qeth_flush_local_addrs);static void qeth_add_local_addrs4 (struct qeth_card *card,struct qeth_ipacmd_local_addrs4 *cmd)
@@ -1501,7 +1499,7 @@ static void qeth_drain_output_queue(struct qeth_qdio_out_q *q, bool free) } } -void qeth_drain_output_queues (struct qeth_card *card) +static void qeth_drain_output_queues (struct qeth_card *card) {int i;
@@ -1512,7 +1510,6 @@ void qeth_drain_output_queues(struct qeth_card *card)qeth_drain_output_queue (card->qdio.out_qs[i], false); } } -EXPORT_SYMBOL_GPL (qeth_drain_output_queues);static int qeth_osa_set_output_queues (struct qeth_card *card,bool single) {
@@ -1840,7 +1837,7 @@ static int qeth_clear_halt_card(struct qeth_card *card, int halt)return qeth_clear_channels (card); } -int qeth_qdio_clear_card (struct qeth_card *card,int use_halt) +static int qeth_qdio_clear_card (struct qeth_card *card,int use_halt) {int rc =0 ;
@@ -1868,7 +1865,6 @@ int qeth_qdio_clear_card(struct qeth_card *card, int use_halt)QETH_CARD_TEXT_ (card,3 ,"2err%d" , rc);return rc; } -EXPORT_SYMBOL_GPL (qeth_qdio_clear_card);static enum qeth_discipline_id qeth_vm_detect_layer (struct qeth_card *card) {
@@ -5333,6 +5329,10 @@ static int qeth_set_online(struct qeth_card *card) err_online: err_hardsetup: +qeth_qdio_clear_card (card,0 ); +qeth_clear_working_pool_list (card); +qeth_flush_local_addrs (card); +qeth_stop_channel (&card->data);qeth_stop_channel (&card->write);qeth_stop_channel (&card->read);
@@ -5366,8 +5366,16 @@ int qeth_set_offline(struct qeth_card *card, bool resetting)netif_carrier_off (card->dev);rtnl_unlock (); +cancel_work_sync (&card->rx_mode_work); + card->discipline->set_offline (card); +qeth_qdio_clear_card (card,0 ); +qeth_drain_output_queues (card); +qeth_clear_working_pool_list (card); +qeth_flush_local_addrs (card); + card->info.promisc_mode =0 ; + rc =qeth_stop_channel (&card->data); rc2 =qeth_stop_channel (&card->write); rc3 =qeth_stop_channel (&card->read);
drivers/s390/net/qeth_l2_main.c +18 -32
73 lines not on this page · raw message
drivers/s390/net/qeth_l3_main.c +16 -30
69 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 9/9 s390/qeth: remove forward declarations in L2 code
In reply to Julian WiedmannShuffle some code around (primarily all the discipline-related stuff) to get rid of all the unnecessary forward declarations.
--- drivers/s390/net/qeth_l2.h | 7 + drivers/s390/net/qeth_l2_main.c | 378 +++++++++++++++----------------- 2 files changed, 188 insertions(+), 197 deletions(-)
drivers/s390/net/qeth_l2.h +7 -0
@@ -31,4 +31,11 @@ struct qeth_mac { struct hlist_node hnode; }; +static inline bool qeth_bridgeport_is_in_use (struct qeth_card *card) +{ +return card->options.sbp.role || + card->options.sbp.reflect_promisc || + card->options.sbp.hostnotification; +} +#endif /* __QETH_L2_H__ */
drivers/s390/net/qeth_l2_main.c +181 -197
420 lines not on this page · raw message
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Wed, 23 Sep 2020 10:36:51 +0200
Quoted 5 lines
please apply the following patch series for qeth to netdev's net-next tree.
This brings all sorts of cleanups. Highlights are more code sharing in the init/teardown paths, and more fine-grained rollback on errors during initialization (instead of a full-blown teardown).
Series applied, thank you.