Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 's390-next'

Julian Wiedmann says:

====================
s390/qeth: updates 2019-04-17

please apply some additional qeth patches to net-next. This patchset
converts the driver to use the kernel's multiqueue model.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+233 -152
+22 -14
drivers/s390/net/qeth_core.h
··· 219 219 /* QDIO queue and buffer handling */ 220 220 /*****************************************************************************/ 221 221 #define QETH_MAX_QUEUES 4 222 + #define QETH_IQD_MIN_TXQ 2 /* One for ucast, one for mcast. */ 223 + #define QETH_IQD_MCAST_TXQ 0 224 + #define QETH_IQD_MIN_UCAST_TXQ 1 222 225 #define QETH_IN_BUF_SIZE_DEFAULT 65536 223 226 #define QETH_IN_BUF_COUNT_DEFAULT 64 224 227 #define QETH_IN_BUF_COUNT_HSDEFAULT 128 ··· 467 464 u64 rx_errors; 468 465 u64 rx_dropped; 469 466 u64 rx_multicast; 470 - u64 tx_errors; 471 467 }; 472 468 473 469 struct qeth_out_q_stats { ··· 481 479 u64 skbs_linearized_fail; 482 480 u64 tso_bytes; 483 481 u64 packing_mode_switch; 482 + u64 stopped; 484 483 485 484 /* rtnl_link_stats64 */ 486 485 u64 tx_packets; ··· 511 508 /* indicates whether PCI flag must be set (or if one is outstanding) */ 512 509 atomic_t set_pci_flags_count; 513 510 }; 511 + 512 + static inline bool qeth_out_queue_is_full(struct qeth_qdio_out_q *queue) 513 + { 514 + return atomic_read(&queue->used_buffers) >= QDIO_MAX_BUFFERS_PER_Q; 515 + } 514 516 515 517 struct qeth_qdio_info { 516 518 atomic_t state; ··· 844 836 return dev->netdev_ops != NULL; 845 837 } 846 838 839 + static inline u16 qeth_iqd_translate_txq(struct net_device *dev, u16 txq) 840 + { 841 + if (txq == QETH_IQD_MCAST_TXQ) 842 + return dev->num_tx_queues - 1; 843 + if (txq == dev->num_tx_queues - 1) 844 + return QETH_IQD_MCAST_TXQ; 845 + return txq; 846 + } 847 + 847 848 static inline void qeth_scrub_qdio_buffer(struct qdio_buffer *buf, 848 849 unsigned int elements) 849 850 { ··· 948 931 data, QETH_PROT_IPV6); 949 932 } 950 933 951 - int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, 952 - int ipv); 953 - static inline struct qeth_qdio_out_q *qeth_get_tx_queue(struct qeth_card *card, 954 - struct sk_buff *skb, 955 - int ipv, int cast_type) 956 - { 957 - if (IS_IQD(card) && cast_type != RTN_UNICAST) 958 - return card->qdio.out_qs[card->qdio.no_out_queues - 1]; 959 - if (!card->qdio.do_prio_queueing) 960 - return card->qdio.out_qs[card->qdio.default_out_queue]; 961 - return card->qdio.out_qs[qeth_get_priority_queue(card, skb, ipv)]; 962 - } 934 + int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb); 963 935 964 936 extern struct qeth_discipline qeth_l2_discipline; 965 937 extern struct qeth_discipline qeth_l3_discipline; ··· 994 988 int qeth_qdio_clear_card(struct qeth_card *, int); 995 989 void qeth_clear_working_pool_list(struct qeth_card *); 996 990 void qeth_clear_cmd_buffers(struct qeth_channel *); 997 - void qeth_clear_qdio_buffers(struct qeth_card *); 991 + void qeth_drain_output_queues(struct qeth_card *card); 998 992 void qeth_setadp_promisc_mode(struct qeth_card *); 999 993 int qeth_setadpparms_change_macaddr(struct qeth_card *); 1000 994 void qeth_tx_timeout(struct net_device *); ··· 1029 1023 struct net_device *dev, 1030 1024 netdev_features_t features); 1031 1025 void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats); 1026 + u16 qeth_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, 1027 + u8 cast_type, struct net_device *sb_dev); 1032 1028 int qeth_open(struct net_device *dev); 1033 1029 int qeth_stop(struct net_device *dev); 1034 1030
+137 -97
drivers/s390/net/qeth_core_main.c
··· 67 67 static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *); 68 68 static void qeth_free_buffer_pool(struct qeth_card *); 69 69 static int qeth_qdio_establish(struct qeth_card *); 70 - static void qeth_free_qdio_buffers(struct qeth_card *); 70 + static void qeth_free_qdio_queues(struct qeth_card *card); 71 71 static void qeth_notify_skbs(struct qeth_qdio_out_q *queue, 72 72 struct qeth_qdio_out_buffer *buf, 73 73 enum iucv_tx_notify notification); ··· 1178 1178 atomic_set(&buf->state, QETH_QDIO_BUF_EMPTY); 1179 1179 } 1180 1180 1181 - static void qeth_clear_outq_buffers(struct qeth_qdio_out_q *q, int free) 1181 + static void qeth_drain_output_queue(struct qeth_qdio_out_q *q, bool free) 1182 1182 { 1183 1183 int j; 1184 1184 ··· 1194 1194 } 1195 1195 } 1196 1196 1197 - void qeth_clear_qdio_buffers(struct qeth_card *card) 1197 + void qeth_drain_output_queues(struct qeth_card *card) 1198 1198 { 1199 1199 int i; 1200 1200 1201 1201 QETH_CARD_TEXT(card, 2, "clearqdbf"); 1202 1202 /* clear outbound buffers to free skbs */ 1203 1203 for (i = 0; i < card->qdio.no_out_queues; ++i) { 1204 - if (card->qdio.out_qs[i]) { 1205 - qeth_clear_outq_buffers(card->qdio.out_qs[i], 0); 1206 - } 1204 + if (card->qdio.out_qs[i]) 1205 + qeth_drain_output_queue(card->qdio.out_qs[i], false); 1207 1206 } 1208 1207 } 1209 - EXPORT_SYMBOL_GPL(qeth_clear_qdio_buffers); 1208 + EXPORT_SYMBOL_GPL(qeth_drain_output_queues); 1210 1209 1211 1210 static void qeth_free_buffer_pool(struct qeth_card *card) 1212 1211 { ··· 1275 1276 return 0; 1276 1277 } 1277 1278 1278 - static void qeth_set_single_write_queues(struct qeth_card *card) 1279 + static void qeth_osa_set_output_queues(struct qeth_card *card, bool single) 1279 1280 { 1280 - if ((atomic_read(&card->qdio.state) != QETH_QDIO_UNINITIALIZED) && 1281 - (card->qdio.no_out_queues == 4)) 1282 - qeth_free_qdio_buffers(card); 1281 + unsigned int count = single ? 1 : card->dev->num_tx_queues; 1283 1282 1284 - card->qdio.no_out_queues = 1; 1285 - if (card->qdio.default_out_queue != 0) 1283 + rtnl_lock(); 1284 + netif_set_real_num_tx_queues(card->dev, count); 1285 + rtnl_unlock(); 1286 + 1287 + if (card->qdio.no_out_queues == count) 1288 + return; 1289 + 1290 + if (atomic_read(&card->qdio.state) != QETH_QDIO_UNINITIALIZED) 1291 + qeth_free_qdio_queues(card); 1292 + 1293 + if (count == 1) 1286 1294 dev_info(&card->gdev->dev, "Priority Queueing not supported\n"); 1287 1295 1288 - card->qdio.default_out_queue = 0; 1296 + card->qdio.default_out_queue = single ? 0 : QETH_DEFAULT_QUEUE; 1297 + card->qdio.no_out_queues = count; 1289 1298 } 1290 1299 1291 - static void qeth_set_multiple_write_queues(struct qeth_card *card) 1292 - { 1293 - if ((atomic_read(&card->qdio.state) != QETH_QDIO_UNINITIALIZED) && 1294 - (card->qdio.no_out_queues == 1)) { 1295 - qeth_free_qdio_buffers(card); 1296 - card->qdio.default_out_queue = 2; 1297 - } 1298 - card->qdio.no_out_queues = 4; 1299 - } 1300 - 1301 - static void qeth_update_from_chp_desc(struct qeth_card *card) 1300 + static int qeth_update_from_chp_desc(struct qeth_card *card) 1302 1301 { 1303 1302 struct ccw_device *ccwdev; 1304 1303 struct channel_path_desc_fmt0 *chp_dsc; ··· 1306 1309 ccwdev = card->data.ccwdev; 1307 1310 chp_dsc = ccw_device_get_chp_desc(ccwdev, 0); 1308 1311 if (!chp_dsc) 1309 - goto out; 1312 + return -ENOMEM; 1310 1313 1311 1314 card->info.func_level = 0x4100 + chp_dsc->desc; 1312 - if (card->info.type == QETH_CARD_TYPE_IQD) 1313 - goto out; 1314 1315 1315 - /* CHPP field bit 6 == 1 -> single queue */ 1316 - if ((chp_dsc->chpp & 0x02) == 0x02) 1317 - qeth_set_single_write_queues(card); 1318 - else 1319 - qeth_set_multiple_write_queues(card); 1320 - out: 1316 + if (IS_OSD(card) || IS_OSX(card)) 1317 + /* CHPP field bit 6 == 1 -> single queue */ 1318 + qeth_osa_set_output_queues(card, chp_dsc->chpp & 0x02); 1319 + 1321 1320 kfree(chp_dsc); 1322 1321 QETH_DBF_TEXT_(SETUP, 2, "nr:%x", card->qdio.no_out_queues); 1323 1322 QETH_DBF_TEXT_(SETUP, 2, "lvl:%02x", card->info.func_level); 1323 + return 0; 1324 1324 } 1325 1325 1326 1326 static void qeth_init_qdio_info(struct qeth_card *card) ··· 1326 1332 atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); 1327 1333 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; 1328 1334 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 1329 - card->qdio.no_out_queues = QETH_MAX_QUEUES; 1330 1335 1331 1336 /* inbound */ 1332 1337 card->qdio.no_in_queues = 1; ··· 2170 2177 /* adjust RX buffer size to new max MTU: */ 2171 2178 card->qdio.in_buf_size = max_mtu + 2 * PAGE_SIZE; 2172 2179 if (dev->max_mtu && dev->max_mtu != max_mtu) 2173 - qeth_free_qdio_buffers(card); 2180 + qeth_free_qdio_queues(card); 2174 2181 } else { 2175 2182 if (dev->mtu) 2176 2183 new_mtu = dev->mtu; ··· 2343 2350 if (!q) 2344 2351 return; 2345 2352 2346 - qeth_clear_outq_buffers(q, 1); 2353 + qeth_drain_output_queue(q, true); 2347 2354 qdio_free_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q); 2348 2355 kfree(q); 2349 2356 } 2350 2357 2351 - static struct qeth_qdio_out_q *qeth_alloc_qdio_out_buf(void) 2358 + static struct qeth_qdio_out_q *qeth_alloc_output_queue(void) 2352 2359 { 2353 2360 struct qeth_qdio_out_q *q = kzalloc(sizeof(*q), GFP_KERNEL); 2354 2361 ··· 2362 2369 return q; 2363 2370 } 2364 2371 2365 - static int qeth_alloc_qdio_buffers(struct qeth_card *card) 2372 + static int qeth_alloc_qdio_queues(struct qeth_card *card) 2366 2373 { 2367 2374 int i, j; 2368 2375 ··· 2383 2390 2384 2391 /* outbound */ 2385 2392 for (i = 0; i < card->qdio.no_out_queues; ++i) { 2386 - card->qdio.out_qs[i] = qeth_alloc_qdio_out_buf(); 2393 + card->qdio.out_qs[i] = qeth_alloc_output_queue(); 2387 2394 if (!card->qdio.out_qs[i]) 2388 2395 goto out_freeoutq; 2389 2396 QETH_DBF_TEXT_(SETUP, 2, "outq %i", i); ··· 2424 2431 return -ENOMEM; 2425 2432 } 2426 2433 2427 - static void qeth_free_qdio_buffers(struct qeth_card *card) 2434 + static void qeth_free_qdio_queues(struct qeth_card *card) 2428 2435 { 2429 2436 int i, j; 2430 2437 ··· 2531 2538 QETH_DBF_TEXT_(SETUP, 2, "5err%d", rc); 2532 2539 goto out_qdio; 2533 2540 } 2534 - rc = qeth_alloc_qdio_buffers(card); 2541 + rc = qeth_alloc_qdio_queues(card); 2535 2542 if (rc) { 2536 2543 QETH_DBF_TEXT_(SETUP, 2, "5err%d", rc); 2537 2544 goto out_qdio; ··· 2539 2546 rc = qeth_qdio_establish(card); 2540 2547 if (rc) { 2541 2548 QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); 2542 - qeth_free_qdio_buffers(card); 2549 + qeth_free_qdio_queues(card); 2543 2550 goto out_qdio; 2544 2551 } 2545 2552 rc = qeth_qdio_activate(card); ··· 3364 3371 } 3365 3372 3366 3373 QETH_TXQ_STAT_ADD(queue, bufs, count); 3367 - netif_trans_update(queue->card->dev); 3368 3374 qdio_flags = QDIO_FLAG_SYNC_OUTPUT; 3369 3375 if (atomic_read(&queue->set_pci_flags_count)) 3370 3376 qdio_flags |= QDIO_FLAG_PCI_OUT; 3371 - atomic_add(count, &queue->used_buffers); 3372 3377 rc = do_QDIO(CARD_DDEV(queue->card), qdio_flags, 3373 3378 queue->queue_no, index, count); 3374 3379 if (rc) { ··· 3406 3415 * do_send_packet. So, we check if there is a 3407 3416 * packing buffer to be flushed here. 3408 3417 */ 3409 - netif_stop_queue(queue->card->dev); 3410 3418 index = queue->next_buf_to_fill; 3411 3419 q_was_packing = queue->do_pack; 3412 3420 /* queue->do_pack may change */ ··· 3450 3460 goto out; 3451 3461 } 3452 3462 3453 - qeth_free_qdio_buffers(card); 3463 + qeth_free_qdio_queues(card); 3454 3464 card->options.cq = cq; 3455 3465 rc = 0; 3456 3466 } ··· 3476 3486 QETH_CARD_TEXT_(card, 5, "qcqherr%d", qdio_err); 3477 3487 3478 3488 if (qdio_err) { 3479 - netif_stop_queue(card->dev); 3489 + netif_tx_stop_all_queues(card->dev); 3480 3490 qeth_schedule_recovery(card); 3481 3491 return; 3482 3492 } ··· 3532 3542 struct qeth_card *card = (struct qeth_card *) card_ptr; 3533 3543 struct qeth_qdio_out_q *queue = card->qdio.out_qs[__queue]; 3534 3544 struct qeth_qdio_out_buffer *buffer; 3545 + struct net_device *dev = card->dev; 3546 + struct netdev_queue *txq; 3535 3547 int i; 3536 3548 3537 3549 QETH_CARD_TEXT(card, 6, "qdouhdl"); 3538 3550 if (qdio_error & QDIO_ERROR_FATAL) { 3539 3551 QETH_CARD_TEXT(card, 2, "achkcond"); 3540 - netif_stop_queue(card->dev); 3552 + netif_tx_stop_all_queues(dev); 3541 3553 qeth_schedule_recovery(card); 3542 3554 return; 3543 3555 } ··· 3588 3596 if (card->info.type != QETH_CARD_TYPE_IQD) 3589 3597 qeth_check_outbound_queue(queue); 3590 3598 3591 - netif_wake_queue(queue->card->dev); 3592 - } 3593 - 3594 - /* We cannot use outbound queue 3 for unicast packets on HiperSockets */ 3595 - static inline int qeth_cut_iqd_prio(struct qeth_card *card, int queue_num) 3596 - { 3597 - if ((card->info.type == QETH_CARD_TYPE_IQD) && (queue_num == 3)) 3598 - return 2; 3599 - return queue_num; 3599 + if (IS_IQD(card)) 3600 + __queue = qeth_iqd_translate_txq(dev, __queue); 3601 + txq = netdev_get_tx_queue(dev, __queue); 3602 + /* xmit may have observed the full-condition, but not yet stopped the 3603 + * txq. In which case the code below won't trigger. So before returning, 3604 + * xmit will re-check the txq's fill level and wake it up if needed. 3605 + */ 3606 + if (netif_tx_queue_stopped(txq) && !qeth_out_queue_is_full(queue)) 3607 + netif_tx_wake_queue(txq); 3600 3608 } 3601 3609 3602 3610 /** 3603 3611 * Note: Function assumes that we have 4 outbound queues. 3604 3612 */ 3605 - int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, 3606 - int ipv) 3613 + int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb) 3607 3614 { 3608 - __be16 *tci; 3615 + struct vlan_ethhdr *veth = vlan_eth_hdr(skb); 3609 3616 u8 tos; 3610 3617 3611 3618 switch (card->qdio.do_prio_queueing) { 3612 3619 case QETH_PRIO_Q_ING_TOS: 3613 3620 case QETH_PRIO_Q_ING_PREC: 3614 - switch (ipv) { 3621 + switch (qeth_get_ip_version(skb)) { 3615 3622 case 4: 3616 3623 tos = ipv4_get_dsfield(ip_hdr(skb)); 3617 3624 break; ··· 3621 3630 return card->qdio.default_out_queue; 3622 3631 } 3623 3632 if (card->qdio.do_prio_queueing == QETH_PRIO_Q_ING_PREC) 3624 - return qeth_cut_iqd_prio(card, ~tos >> 6 & 3); 3633 + return ~tos >> 6 & 3; 3625 3634 if (tos & IPTOS_MINCOST) 3626 - return qeth_cut_iqd_prio(card, 3); 3635 + return 3; 3627 3636 if (tos & IPTOS_RELIABILITY) 3628 3637 return 2; 3629 3638 if (tos & IPTOS_THROUGHPUT) ··· 3634 3643 case QETH_PRIO_Q_ING_SKB: 3635 3644 if (skb->priority > 5) 3636 3645 return 0; 3637 - return qeth_cut_iqd_prio(card, ~skb->priority >> 1 & 3); 3646 + return ~skb->priority >> 1 & 3; 3638 3647 case QETH_PRIO_Q_ING_VLAN: 3639 - tci = &((struct ethhdr *)skb->data)->h_proto; 3640 - if (be16_to_cpu(*tci) == ETH_P_8021Q) 3641 - return qeth_cut_iqd_prio(card, 3642 - ~be16_to_cpu(*(tci + 1)) >> (VLAN_PRIO_SHIFT + 1) & 3); 3648 + if (veth->h_vlan_proto == htons(ETH_P_8021Q)) 3649 + return ~ntohs(veth->h_vlan_TCI) >> 3650 + (VLAN_PRIO_SHIFT + 1) & 3; 3643 3651 break; 3644 3652 default: 3645 3653 break; ··· 3850 3860 * from qeth_core_header_cache. 3851 3861 * @offset: when mapping the skb, start at skb->data + offset 3852 3862 * @hd_len: if > 0, build a dedicated header element of this size 3863 + * flush: Prepare the buffer to be flushed, regardless of its fill level. 3853 3864 */ 3854 3865 static int qeth_fill_buffer(struct qeth_qdio_out_q *queue, 3855 3866 struct qeth_qdio_out_buffer *buf, 3856 3867 struct sk_buff *skb, struct qeth_hdr *hdr, 3857 - unsigned int offset, unsigned int hd_len) 3868 + unsigned int offset, unsigned int hd_len, 3869 + bool flush) 3858 3870 { 3859 3871 struct qdio_buffer *buffer = buf->buffer; 3860 3872 bool is_first_elem = true; ··· 3885 3893 3886 3894 QETH_TXQ_STAT_INC(queue, skbs_pack); 3887 3895 /* If the buffer still has free elements, keep using it. */ 3888 - if (buf->next_element_to_fill < 3889 - QETH_MAX_BUFFER_ELEMENTS(queue->card)) 3896 + if (!flush && buf->next_element_to_fill < 3897 + QETH_MAX_BUFFER_ELEMENTS(queue->card)) 3890 3898 return 0; 3891 3899 } 3892 3900 ··· 3903 3911 { 3904 3912 int index = queue->next_buf_to_fill; 3905 3913 struct qeth_qdio_out_buffer *buffer = queue->bufs[index]; 3914 + struct netdev_queue *txq; 3915 + bool stopped = false; 3906 3916 3907 - /* 3908 - * check if buffer is empty to make sure that we do not 'overtake' 3909 - * ourselves and try to fill a buffer that is already primed 3917 + /* Just a sanity check, the wake/stop logic should ensure that we always 3918 + * get a free buffer. 3910 3919 */ 3911 3920 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) 3912 3921 return -EBUSY; 3913 - qeth_fill_buffer(queue, buffer, skb, hdr, offset, hd_len); 3922 + 3923 + txq = netdev_get_tx_queue(queue->card->dev, skb_get_queue_mapping(skb)); 3924 + 3925 + if (atomic_inc_return(&queue->used_buffers) >= QDIO_MAX_BUFFERS_PER_Q) { 3926 + /* If a TX completion happens right _here_ and misses to wake 3927 + * the txq, then our re-check below will catch the race. 3928 + */ 3929 + QETH_TXQ_STAT_INC(queue, stopped); 3930 + netif_tx_stop_queue(txq); 3931 + stopped = true; 3932 + } 3933 + 3934 + qeth_fill_buffer(queue, buffer, skb, hdr, offset, hd_len, stopped); 3914 3935 qeth_flush_buffers(queue, index, 1); 3936 + 3937 + if (stopped && !qeth_out_queue_is_full(queue)) 3938 + netif_tx_start_queue(txq); 3915 3939 return 0; 3916 3940 } 3917 3941 ··· 3937 3929 int elements_needed) 3938 3930 { 3939 3931 struct qeth_qdio_out_buffer *buffer; 3932 + struct netdev_queue *txq; 3933 + bool stopped = false; 3940 3934 int start_index; 3941 3935 int flush_count = 0; 3942 3936 int do_pack = 0; ··· 3950 3940 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); 3951 3941 start_index = queue->next_buf_to_fill; 3952 3942 buffer = queue->bufs[queue->next_buf_to_fill]; 3953 - /* 3954 - * check if buffer is empty to make sure that we do not 'overtake' 3955 - * ourselves and try to fill a buffer that is already primed 3943 + 3944 + /* Just a sanity check, the wake/stop logic should ensure that we always 3945 + * get a free buffer. 3956 3946 */ 3957 3947 if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { 3958 3948 atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); 3959 3949 return -EBUSY; 3960 3950 } 3951 + 3952 + txq = netdev_get_tx_queue(card->dev, skb_get_queue_mapping(skb)); 3953 + 3961 3954 /* check if we need to switch packing state of this queue */ 3962 3955 qeth_switch_to_packing_if_needed(queue); 3963 3956 if (queue->do_pack) { ··· 3975 3962 (queue->next_buf_to_fill + 1) % 3976 3963 QDIO_MAX_BUFFERS_PER_Q; 3977 3964 buffer = queue->bufs[queue->next_buf_to_fill]; 3978 - /* we did a step forward, so check buffer state 3979 - * again */ 3965 + 3966 + /* We stepped forward, so sanity-check again: */ 3980 3967 if (atomic_read(&buffer->state) != 3981 3968 QETH_QDIO_BUF_EMPTY) { 3982 3969 qeth_flush_buffers(queue, start_index, ··· 3989 3976 } 3990 3977 } 3991 3978 3992 - flush_count += qeth_fill_buffer(queue, buffer, skb, hdr, offset, 3993 - hd_len); 3979 + if (buffer->next_element_to_fill == 0 && 3980 + atomic_inc_return(&queue->used_buffers) >= QDIO_MAX_BUFFERS_PER_Q) { 3981 + /* If a TX completion happens right _here_ and misses to wake 3982 + * the txq, then our re-check below will catch the race. 3983 + */ 3984 + QETH_TXQ_STAT_INC(queue, stopped); 3985 + netif_tx_stop_queue(txq); 3986 + stopped = true; 3987 + } 3988 + 3989 + flush_count += qeth_fill_buffer(queue, buffer, skb, hdr, offset, hd_len, 3990 + stopped); 3994 3991 if (flush_count) 3995 3992 qeth_flush_buffers(queue, start_index, flush_count); 3996 3993 else if (!atomic_read(&queue->set_pci_flags_count)) ··· 4031 4008 if (do_pack) 4032 4009 QETH_TXQ_STAT_ADD(queue, bufs_pack, flush_count); 4033 4010 4011 + if (stopped && !qeth_out_queue_is_full(queue)) 4012 + netif_tx_start_queue(txq); 4034 4013 return rc; 4035 4014 } 4036 4015 EXPORT_SYMBOL_GPL(qeth_do_send_packet); ··· 4119 4094 } else { 4120 4095 if (!push_len) 4121 4096 kmem_cache_free(qeth_core_header_cache, hdr); 4122 - if (rc == -EBUSY) 4123 - /* roll back to ETH header */ 4124 - skb_pull(skb, push_len); 4125 4097 } 4126 4098 return rc; 4127 4099 } ··· 4363 4341 4364 4342 card = dev->ml_priv; 4365 4343 QETH_CARD_TEXT(card, 4, "txtimeo"); 4366 - QETH_CARD_STAT_INC(card, tx_errors); 4367 4344 qeth_schedule_recovery(card); 4368 4345 } 4369 4346 EXPORT_SYMBOL_GPL(qeth_tx_timeout); ··· 4951 4930 qeth_clean_channel(&card->write); 4952 4931 qeth_clean_channel(&card->data); 4953 4932 destroy_workqueue(card->event_wq); 4954 - qeth_free_qdio_buffers(card); 4933 + qeth_free_qdio_queues(card); 4955 4934 unregister_service_level(&card->qeth_service_level); 4956 4935 dev_set_drvdata(&card->gdev->dev, NULL); 4957 4936 kfree(card); ··· 5000 4979 5001 4980 QETH_DBF_TEXT(SETUP, 2, "hrdsetup"); 5002 4981 atomic_set(&card->force_alloc_skb, 0); 5003 - qeth_update_from_chp_desc(card); 4982 + rc = qeth_update_from_chp_desc(card); 4983 + if (rc) 4984 + return rc; 5004 4985 retry: 5005 4986 if (retries < 3) 5006 4987 QETH_DBF_MESSAGE(2, "Retrying to do IDX activates on device %x.\n", ··· 5580 5557 5581 5558 switch (card->info.type) { 5582 5559 case QETH_CARD_TYPE_IQD: 5583 - dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN, ether_setup); 5560 + dev = alloc_netdev_mqs(0, "hsi%d", NET_NAME_UNKNOWN, 5561 + ether_setup, QETH_MAX_QUEUES, 1); 5562 + break; 5563 + case QETH_CARD_TYPE_OSM: 5564 + dev = alloc_etherdev(0); 5584 5565 break; 5585 5566 case QETH_CARD_TYPE_OSN: 5586 5567 dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN, ether_setup); 5587 5568 break; 5588 5569 default: 5589 - dev = alloc_etherdev(0); 5570 + dev = alloc_etherdev_mqs(0, QETH_MAX_QUEUES, 1); 5590 5571 } 5591 5572 5592 5573 if (!dev) ··· 5612 5585 dev->priv_flags &= ~IFF_TX_SKB_SHARING; 5613 5586 dev->hw_features |= NETIF_F_SG; 5614 5587 dev->vlan_features |= NETIF_F_SG; 5615 - if (IS_IQD(card)) 5588 + if (IS_IQD(card)) { 5589 + netif_set_real_num_tx_queues(dev, QETH_IQD_MIN_TXQ); 5616 5590 dev->features |= NETIF_F_SG; 5591 + } 5617 5592 } 5618 5593 5619 5594 return dev; ··· 5665 5636 } 5666 5637 5667 5638 qeth_setup_card(card); 5668 - qeth_update_from_chp_desc(card); 5669 - 5670 5639 card->dev = qeth_alloc_netdev(card); 5671 5640 if (!card->dev) { 5672 5641 rc = -ENOMEM; 5673 5642 goto err_card; 5674 5643 } 5675 5644 5645 + card->qdio.no_out_queues = card->dev->num_tx_queues; 5646 + rc = qeth_update_from_chp_desc(card); 5647 + if (rc) 5648 + goto err_chp_desc; 5676 5649 qeth_determine_capabilities(card); 5677 5650 enforced_disc = qeth_enforce_discipline(card); 5678 5651 switch (enforced_disc) { ··· 5701 5670 err_disc: 5702 5671 qeth_core_free_discipline(card); 5703 5672 err_load: 5673 + err_chp_desc: 5704 5674 free_netdev(card->dev); 5705 5675 err_card: 5706 5676 qeth_core_free_card(card); ··· 5764 5732 if ((gdev->state == CCWGROUP_ONLINE) && card->info.hwtrap) 5765 5733 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 5766 5734 qeth_qdio_clear_card(card, 0); 5767 - qeth_clear_qdio_buffers(card); 5735 + qeth_drain_output_queues(card); 5768 5736 qdio_free(CARD_DDEV(card)); 5769 5737 } 5770 5738 ··· 6220 6188 stats->rx_errors = card->stats.rx_errors; 6221 6189 stats->rx_dropped = card->stats.rx_dropped; 6222 6190 stats->multicast = card->stats.rx_multicast; 6223 - stats->tx_errors = card->stats.tx_errors; 6224 6191 6225 6192 for (i = 0; i < card->qdio.no_out_queues; i++) { 6226 6193 queue = card->qdio.out_qs[i]; ··· 6232 6201 } 6233 6202 EXPORT_SYMBOL_GPL(qeth_get_stats64); 6234 6203 6204 + u16 qeth_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, 6205 + u8 cast_type, struct net_device *sb_dev) 6206 + { 6207 + if (cast_type != RTN_UNICAST) 6208 + return QETH_IQD_MCAST_TXQ; 6209 + return QETH_IQD_MIN_UCAST_TXQ; 6210 + } 6211 + EXPORT_SYMBOL_GPL(qeth_iqd_select_queue); 6212 + 6235 6213 int qeth_open(struct net_device *dev) 6236 6214 { 6237 6215 struct qeth_card *card = dev->ml_priv; ··· 6251 6211 return -EIO; 6252 6212 6253 6213 card->data.state = CH_STATE_UP; 6254 - netif_start_queue(dev); 6214 + netif_tx_start_all_queues(dev); 6255 6215 6256 6216 napi_enable(&card->napi); 6257 6217 local_bh_disable();
+3 -4
drivers/s390/net/qeth_core_sys.c
··· 198 198 if (!card) 199 199 return -EINVAL; 200 200 201 + if (IS_IQD(card)) 202 + return -EOPNOTSUPP; 203 + 201 204 mutex_lock(&card->conf_mutex); 202 205 if (card->state != CARD_STATE_DOWN) { 203 206 rc = -EPERM; ··· 242 239 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 243 240 card->qdio.default_out_queue = 2; 244 241 } else if (sysfs_streq(buf, "no_prio_queueing:3")) { 245 - if (card->info.type == QETH_CARD_TYPE_IQD) { 246 - rc = -EPERM; 247 - goto out; 248 - } 249 242 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 250 243 card->qdio.default_out_queue = 3; 251 244 } else if (sysfs_streq(buf, "no_prio_queueing")) {
+17
drivers/s390/net/qeth_ethtool.c
··· 38 38 QETH_TXQ_STAT("linearized+error skbs", skbs_linearized_fail), 39 39 QETH_TXQ_STAT("TSO bytes", tso_bytes), 40 40 QETH_TXQ_STAT("Packing mode switches", packing_mode_switch), 41 + QETH_TXQ_STAT("Queue stopped", stopped), 41 42 }; 42 43 43 44 static const struct qeth_stats card_stats[] = { ··· 153 152 sizeof(info->fw_version)); 154 153 snprintf(info->bus_info, sizeof(info->bus_info), "%s/%s/%s", 155 154 CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card)); 155 + } 156 + 157 + static void qeth_get_channels(struct net_device *dev, 158 + struct ethtool_channels *channels) 159 + { 160 + struct qeth_card *card = dev->ml_priv; 161 + 162 + channels->max_rx = dev->num_rx_queues; 163 + channels->max_tx = card->qdio.no_out_queues; 164 + channels->max_other = 0; 165 + channels->max_combined = 0; 166 + channels->rx_count = dev->real_num_rx_queues; 167 + channels->tx_count = dev->real_num_tx_queues; 168 + channels->other_count = 0; 169 + channels->combined_count = 0; 156 170 } 157 171 158 172 /* Helper function to fill 'advertising' and 'supported' which are the same. */ ··· 375 359 .get_ethtool_stats = qeth_get_ethtool_stats, 376 360 .get_sset_count = qeth_get_sset_count, 377 361 .get_drvinfo = qeth_get_drvinfo, 362 + .get_channels = qeth_get_channels, 378 363 .get_link_ksettings = qeth_get_link_ksettings, 379 364 }; 380 365
+22 -16
drivers/s390/net/qeth_l2_main.c
··· 161 161 } 162 162 } 163 163 164 - static int qeth_l2_get_cast_type(struct qeth_card *card, struct sk_buff *skb) 164 + static int qeth_l2_get_cast_type(struct sk_buff *skb) 165 165 { 166 - if (card->info.type == QETH_CARD_TYPE_OSN) 167 - return RTN_UNICAST; 168 166 if (is_broadcast_ether_addr(skb->data)) 169 167 return RTN_BROADCAST; 170 168 if (is_multicast_ether_addr(skb->data)) ··· 297 299 } 298 300 if (card->state == CARD_STATE_HARDSETUP) { 299 301 qeth_qdio_clear_card(card, 0); 300 - qeth_clear_qdio_buffers(card); 302 + qeth_drain_output_queues(card); 301 303 qeth_clear_working_pool_list(card); 302 304 card->state = CARD_STATE_DOWN; 303 305 } ··· 601 603 struct net_device *dev) 602 604 { 603 605 struct qeth_card *card = dev->ml_priv; 604 - int cast_type = qeth_l2_get_cast_type(card, skb); 605 - int ipv = qeth_get_ip_version(skb); 606 + u16 txq = skb_get_queue_mapping(skb); 606 607 struct qeth_qdio_out_q *queue; 607 608 int tx_bytes = skb->len; 608 609 int rc; 609 610 610 - queue = qeth_get_tx_queue(card, skb, ipv, cast_type); 611 - 612 - netif_stop_queue(dev); 611 + if (IS_IQD(card)) 612 + txq = qeth_iqd_translate_txq(dev, txq); 613 + queue = card->qdio.out_qs[txq]; 613 614 614 615 if (IS_OSN(card)) 615 616 rc = qeth_l2_xmit_osn(card, skb, queue); 616 617 else 617 - rc = qeth_xmit(card, skb, queue, ipv, cast_type, 618 - qeth_l2_fill_header); 618 + rc = qeth_xmit(card, skb, queue, qeth_get_ip_version(skb), 619 + qeth_l2_get_cast_type(skb), qeth_l2_fill_header); 619 620 620 621 if (!rc) { 621 622 QETH_TXQ_STAT_INC(queue, tx_packets); 622 623 QETH_TXQ_STAT_ADD(queue, tx_bytes, tx_bytes); 623 - netif_wake_queue(dev); 624 624 return NETDEV_TX_OK; 625 - } else if (rc == -EBUSY) { 626 - return NETDEV_TX_BUSY; 627 - } /* else fall through */ 625 + } 628 626 629 627 QETH_TXQ_STAT_INC(queue, tx_dropped); 630 628 kfree_skb(skb); 631 - netif_wake_queue(dev); 632 629 return NETDEV_TX_OK; 630 + } 631 + 632 + static u16 qeth_l2_select_queue(struct net_device *dev, struct sk_buff *skb, 633 + struct net_device *sb_dev) 634 + { 635 + struct qeth_card *card = dev->ml_priv; 636 + 637 + if (IS_IQD(card)) 638 + return qeth_iqd_select_queue(dev, skb, 639 + qeth_l2_get_cast_type(skb), 640 + sb_dev); 641 + return qeth_get_priority_queue(card, skb); 633 642 } 634 643 635 644 static const struct device_type qeth_l2_devtype = { ··· 692 687 .ndo_get_stats64 = qeth_get_stats64, 693 688 .ndo_start_xmit = qeth_l2_hard_start_xmit, 694 689 .ndo_features_check = qeth_features_check, 690 + .ndo_select_queue = qeth_l2_select_queue, 695 691 .ndo_validate_addr = qeth_l2_validate_addr, 696 692 .ndo_set_rx_mode = qeth_l2_set_rx_mode, 697 693 .ndo_do_ioctl = qeth_do_ioctl,
+32 -21
drivers/s390/net/qeth_l3_main.c
··· 1433 1433 } 1434 1434 if (card->state == CARD_STATE_HARDSETUP) { 1435 1435 qeth_qdio_clear_card(card, 0); 1436 - qeth_clear_qdio_buffers(card); 1436 + qeth_drain_output_queues(card); 1437 1437 qeth_clear_working_pool_list(card); 1438 1438 card->state = CARD_STATE_DOWN; 1439 1439 } ··· 2036 2036 static int qeth_l3_xmit(struct qeth_card *card, struct sk_buff *skb, 2037 2037 struct qeth_qdio_out_q *queue, int ipv, int cast_type) 2038 2038 { 2039 - unsigned char eth_hdr[ETH_HLEN]; 2040 2039 unsigned int hw_hdr_len; 2041 2040 int rc; 2042 2041 ··· 2045 2046 rc = skb_cow_head(skb, hw_hdr_len - ETH_HLEN); 2046 2047 if (rc) 2047 2048 return rc; 2048 - skb_copy_from_linear_data(skb, eth_hdr, ETH_HLEN); 2049 2049 skb_pull(skb, ETH_HLEN); 2050 2050 2051 2051 qeth_l3_fixup_headers(skb); 2052 - rc = qeth_xmit(card, skb, queue, ipv, cast_type, qeth_l3_fill_header); 2053 - if (rc == -EBUSY) { 2054 - /* roll back to ETH header */ 2055 - skb_push(skb, ETH_HLEN); 2056 - skb_copy_to_linear_data(skb, eth_hdr, ETH_HLEN); 2057 - } 2058 - return rc; 2052 + return qeth_xmit(card, skb, queue, ipv, cast_type, qeth_l3_fill_header); 2059 2053 } 2060 2054 2061 2055 static netdev_tx_t qeth_l3_hard_start_xmit(struct sk_buff *skb, 2062 2056 struct net_device *dev) 2063 2057 { 2064 - int cast_type = qeth_l3_get_cast_type(skb); 2065 2058 struct qeth_card *card = dev->ml_priv; 2059 + u16 txq = skb_get_queue_mapping(skb); 2066 2060 int ipv = qeth_get_ip_version(skb); 2067 2061 struct qeth_qdio_out_q *queue; 2068 2062 int tx_bytes = skb->len; 2069 - int rc; 2070 - 2071 - queue = qeth_get_tx_queue(card, skb, ipv, cast_type); 2063 + int cast_type, rc; 2072 2064 2073 2065 if (IS_IQD(card)) { 2066 + queue = card->qdio.out_qs[qeth_iqd_translate_txq(dev, txq)]; 2067 + 2074 2068 if (card->options.sniffer) 2075 2069 goto tx_drop; 2076 2070 if ((card->options.cq != QETH_CQ_ENABLED && !ipv) || 2077 2071 (card->options.cq == QETH_CQ_ENABLED && 2078 2072 skb->protocol != htons(ETH_P_AF_IUCV))) 2079 2073 goto tx_drop; 2074 + 2075 + if (txq == QETH_IQD_MCAST_TXQ) 2076 + cast_type = qeth_l3_get_cast_type(skb); 2077 + else 2078 + cast_type = RTN_UNICAST; 2079 + } else { 2080 + queue = card->qdio.out_qs[txq]; 2081 + cast_type = qeth_l3_get_cast_type(skb); 2080 2082 } 2081 2083 2082 2084 if (cast_type == RTN_BROADCAST && !card->info.broadcast_capable) 2083 2085 goto tx_drop; 2084 - 2085 - netif_stop_queue(dev); 2086 2086 2087 2087 if (ipv == 4 || IS_IQD(card)) 2088 2088 rc = qeth_l3_xmit(card, skb, queue, ipv, cast_type); ··· 2092 2094 if (!rc) { 2093 2095 QETH_TXQ_STAT_INC(queue, tx_packets); 2094 2096 QETH_TXQ_STAT_ADD(queue, tx_bytes, tx_bytes); 2095 - netif_wake_queue(dev); 2096 2097 return NETDEV_TX_OK; 2097 - } else if (rc == -EBUSY) { 2098 - return NETDEV_TX_BUSY; 2099 - } /* else fall through */ 2098 + } 2100 2099 2101 2100 tx_drop: 2102 2101 QETH_TXQ_STAT_INC(queue, tx_dropped); 2103 2102 kfree_skb(skb); 2104 - netif_wake_queue(dev); 2105 2103 return NETDEV_TX_OK; 2106 2104 } 2107 2105 ··· 2141 2147 return qeth_features_check(skb, dev, features); 2142 2148 } 2143 2149 2150 + static u16 qeth_l3_iqd_select_queue(struct net_device *dev, struct sk_buff *skb, 2151 + struct net_device *sb_dev) 2152 + { 2153 + return qeth_iqd_select_queue(dev, skb, qeth_l3_get_cast_type(skb), 2154 + sb_dev); 2155 + } 2156 + 2157 + static u16 qeth_l3_osa_select_queue(struct net_device *dev, struct sk_buff *skb, 2158 + struct net_device *sb_dev) 2159 + { 2160 + struct qeth_card *card = dev->ml_priv; 2161 + 2162 + return qeth_get_priority_queue(card, skb); 2163 + } 2164 + 2144 2165 static const struct net_device_ops qeth_l3_netdev_ops = { 2145 2166 .ndo_open = qeth_open, 2146 2167 .ndo_stop = qeth_stop, 2147 2168 .ndo_get_stats64 = qeth_get_stats64, 2148 2169 .ndo_start_xmit = qeth_l3_hard_start_xmit, 2170 + .ndo_select_queue = qeth_l3_iqd_select_queue, 2149 2171 .ndo_validate_addr = eth_validate_addr, 2150 2172 .ndo_set_rx_mode = qeth_l3_set_rx_mode, 2151 2173 .ndo_do_ioctl = qeth_do_ioctl, ··· 2178 2168 .ndo_get_stats64 = qeth_get_stats64, 2179 2169 .ndo_start_xmit = qeth_l3_hard_start_xmit, 2180 2170 .ndo_features_check = qeth_l3_osa_features_check, 2171 + .ndo_select_queue = qeth_l3_osa_select_queue, 2181 2172 .ndo_validate_addr = eth_validate_addr, 2182 2173 .ndo_set_rx_mode = qeth_l3_set_rx_mode, 2183 2174 .ndo_do_ioctl = qeth_do_ioctl,