Lines Matching +full:rx +full:- +full:eq

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005 - 2016 Broadcom
7 * linux-drivers@emulex.com
39 /* Per-module error detection/recovery workq shared across all functions.
147 struct be_dma_mem *mem = &q->dma_mem; in be_queue_free()
149 if (mem->va) { in be_queue_free()
150 dma_free_coherent(&adapter->pdev->dev, mem->size, mem->va, in be_queue_free()
151 mem->dma); in be_queue_free()
152 mem->va = NULL; in be_queue_free()
159 struct be_dma_mem *mem = &q->dma_mem; in be_queue_alloc()
162 q->len = len; in be_queue_alloc()
163 q->entry_size = entry_size; in be_queue_alloc()
164 mem->size = len * entry_size; in be_queue_alloc()
165 mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, in be_queue_alloc()
166 &mem->dma, GFP_KERNEL); in be_queue_alloc()
167 if (!mem->va) in be_queue_alloc()
168 return -ENOMEM; in be_queue_alloc()
176 pci_read_config_dword(adapter->pdev, PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET, in be_reg_intr_set()
187 pci_write_config_dword(adapter->pdev, in be_reg_intr_set()
218 iowrite32(val, adapter->db + DB_RQ_OFFSET); in be_rxq_notify()
229 val |= txo->q.id & DB_TXULP_RING_ID_MASK; in be_txq_notify()
233 iowrite32(val, adapter->db + txo->db_offset); in be_txq_notify()
255 iowrite32(val, adapter->db + DB_EQ_OFFSET); in be_eq_notify()
272 iowrite32(val, adapter->db + DB_CQ_OFFSET); in be_cq_notify()
279 /* Check if mac has already been added as part of uc-list */ in be_dev_mac_add()
280 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_add()
281 if (ether_addr_equal(adapter->uc_list[i].mac, mac)) { in be_dev_mac_add()
283 adapter->pmac_id[0] = adapter->pmac_id[i + 1]; in be_dev_mac_add()
288 return be_cmd_pmac_add(adapter, mac, adapter->if_handle, in be_dev_mac_add()
289 &adapter->pmac_id[0], 0); in be_dev_mac_add()
297 * being used in uc-list in be_dev_mac_del()
299 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_del()
300 if (adapter->pmac_id[i + 1] == pmac_id) in be_dev_mac_del()
303 be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0); in be_dev_mac_del()
309 struct device *dev = &adapter->pdev->dev; in be_mac_addr_set()
313 u32 old_pmac_id = adapter->pmac_id[0]; in be_mac_addr_set()
315 if (!is_valid_ether_addr(addr->sa_data)) in be_mac_addr_set()
316 return -EADDRNOTAVAIL; in be_mac_addr_set()
321 if (ether_addr_equal(addr->sa_data, adapter->dev_mac)) in be_mac_addr_set()
329 return -EPERM; in be_mac_addr_set()
331 /* if device is not running, copy MAC to netdev->dev_addr */ in be_mac_addr_set()
341 mutex_lock(&adapter->rx_filter_lock); in be_mac_addr_set()
342 status = be_dev_mac_add(adapter, (u8 *)addr->sa_data); in be_mac_addr_set()
348 if (adapter->pmac_id[0] != old_pmac_id) in be_mac_addr_set()
352 mutex_unlock(&adapter->rx_filter_lock); in be_mac_addr_set()
356 status = be_cmd_get_active_mac(adapter, adapter->pmac_id[0], mac, in be_mac_addr_set()
357 adapter->if_handle, true, 0); in be_mac_addr_set()
362 * or PF didn't pre-provision. in be_mac_addr_set()
364 if (!ether_addr_equal(addr->sa_data, mac)) { in be_mac_addr_set()
365 status = -EPERM; in be_mac_addr_set()
370 ether_addr_copy(adapter->dev_mac, addr->sa_data); in be_mac_addr_set()
372 ether_addr_copy(netdev->dev_addr, addr->sa_data); in be_mac_addr_set()
373 dev_info(dev, "MAC address changed to %pM\n", addr->sa_data); in be_mac_addr_set()
376 dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data); in be_mac_addr_set()
384 struct be_cmd_resp_get_stats_v0 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
386 return &cmd->hw_stats; in hw_stats_from_cmd()
388 struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
390 return &cmd->hw_stats; in hw_stats_from_cmd()
392 struct be_cmd_resp_get_stats_v2 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
394 return &cmd->hw_stats; in hw_stats_from_cmd()
404 return &hw_stats->erx; in be_erx_stats_from_cmd()
408 return &hw_stats->erx; in be_erx_stats_from_cmd()
412 return &hw_stats->erx; in be_erx_stats_from_cmd()
419 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v0_stats()
420 struct be_rxf_stats_v0 *rxf_stats = &hw_stats->rxf; in populate_be_v0_stats()
422 &rxf_stats->port[adapter->port_num]; in populate_be_v0_stats()
423 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v0_stats()
426 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v0_stats()
427 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v0_stats()
428 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v0_stats()
429 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v0_stats()
430 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v0_stats()
431 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v0_stats()
432 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v0_stats()
433 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v0_stats()
434 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v0_stats()
435 drvs->rxpp_fifo_overflow_drop = port_stats->rx_fifo_overflow; in populate_be_v0_stats()
436 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v0_stats()
437 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v0_stats()
438 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v0_stats()
439 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v0_stats()
440 drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow; in populate_be_v0_stats()
441 drvs->rx_dropped_header_too_small = in populate_be_v0_stats()
442 port_stats->rx_dropped_header_too_small; in populate_be_v0_stats()
443 drvs->rx_address_filtered = in populate_be_v0_stats()
444 port_stats->rx_address_filtered + in populate_be_v0_stats()
445 port_stats->rx_vlan_filtered; in populate_be_v0_stats()
446 drvs->rx_alignment_symbol_errors = in populate_be_v0_stats()
447 port_stats->rx_alignment_symbol_errors; in populate_be_v0_stats()
449 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v0_stats()
450 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v0_stats()
452 if (adapter->port_num) in populate_be_v0_stats()
453 drvs->jabber_events = rxf_stats->port1_jabber_events; in populate_be_v0_stats()
455 drvs->jabber_events = rxf_stats->port0_jabber_events; in populate_be_v0_stats()
456 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v0_stats()
457 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v0_stats()
458 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v0_stats()
459 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v0_stats()
460 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v0_stats()
461 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v0_stats()
462 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v0_stats()
468 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v1_stats()
469 struct be_rxf_stats_v1 *rxf_stats = &hw_stats->rxf; in populate_be_v1_stats()
471 &rxf_stats->port[adapter->port_num]; in populate_be_v1_stats()
472 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v1_stats()
475 drvs->pmem_fifo_overflow_drop = port_stats->pmem_fifo_overflow_drop; in populate_be_v1_stats()
476 drvs->rx_priority_pause_frames = port_stats->rx_priority_pause_frames; in populate_be_v1_stats()
477 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v1_stats()
478 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v1_stats()
479 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v1_stats()
480 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v1_stats()
481 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v1_stats()
482 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v1_stats()
483 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v1_stats()
484 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v1_stats()
485 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v1_stats()
486 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v1_stats()
487 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v1_stats()
488 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v1_stats()
489 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v1_stats()
490 drvs->rx_dropped_header_too_small = in populate_be_v1_stats()
491 port_stats->rx_dropped_header_too_small; in populate_be_v1_stats()
492 drvs->rx_input_fifo_overflow_drop = in populate_be_v1_stats()
493 port_stats->rx_input_fifo_overflow_drop; in populate_be_v1_stats()
494 drvs->rx_address_filtered = port_stats->rx_address_filtered; in populate_be_v1_stats()
495 drvs->rx_alignment_symbol_errors = in populate_be_v1_stats()
496 port_stats->rx_alignment_symbol_errors; in populate_be_v1_stats()
497 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; in populate_be_v1_stats()
498 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v1_stats()
499 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v1_stats()
500 drvs->tx_priority_pauseframes = port_stats->tx_priority_pauseframes; in populate_be_v1_stats()
501 drvs->jabber_events = port_stats->jabber_events; in populate_be_v1_stats()
502 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v1_stats()
503 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v1_stats()
504 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v1_stats()
505 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v1_stats()
506 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v1_stats()
507 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v1_stats()
508 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v1_stats()
514 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v2_stats()
515 struct be_rxf_stats_v2 *rxf_stats = &hw_stats->rxf; in populate_be_v2_stats()
517 &rxf_stats->port[adapter->port_num]; in populate_be_v2_stats()
518 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v2_stats()
521 drvs->pmem_fifo_overflow_drop = port_stats->pmem_fifo_overflow_drop; in populate_be_v2_stats()
522 drvs->rx_priority_pause_frames = port_stats->rx_priority_pause_frames; in populate_be_v2_stats()
523 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v2_stats()
524 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v2_stats()
525 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v2_stats()
526 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v2_stats()
527 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v2_stats()
528 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v2_stats()
529 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v2_stats()
530 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v2_stats()
531 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v2_stats()
532 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v2_stats()
533 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v2_stats()
534 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v2_stats()
535 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v2_stats()
536 drvs->rx_dropped_header_too_small = in populate_be_v2_stats()
537 port_stats->rx_dropped_header_too_small; in populate_be_v2_stats()
538 drvs->rx_input_fifo_overflow_drop = in populate_be_v2_stats()
539 port_stats->rx_input_fifo_overflow_drop; in populate_be_v2_stats()
540 drvs->rx_address_filtered = port_stats->rx_address_filtered; in populate_be_v2_stats()
541 drvs->rx_alignment_symbol_errors = in populate_be_v2_stats()
542 port_stats->rx_alignment_symbol_errors; in populate_be_v2_stats()
543 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; in populate_be_v2_stats()
544 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v2_stats()
545 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v2_stats()
546 drvs->tx_priority_pauseframes = port_stats->tx_priority_pauseframes; in populate_be_v2_stats()
547 drvs->jabber_events = port_stats->jabber_events; in populate_be_v2_stats()
548 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v2_stats()
549 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v2_stats()
550 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v2_stats()
551 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v2_stats()
552 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v2_stats()
553 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v2_stats()
554 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v2_stats()
556 drvs->rx_roce_bytes_lsd = port_stats->roce_bytes_received_lsd; in populate_be_v2_stats()
557 drvs->rx_roce_bytes_msd = port_stats->roce_bytes_received_msd; in populate_be_v2_stats()
558 drvs->rx_roce_frames = port_stats->roce_frames_received; in populate_be_v2_stats()
559 drvs->roce_drops_crc = port_stats->roce_drops_crc; in populate_be_v2_stats()
560 drvs->roce_drops_payload_len = in populate_be_v2_stats()
561 port_stats->roce_drops_payload_len; in populate_be_v2_stats()
567 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_lancer_stats()
571 drvs->rx_pause_frames = pport_stats->rx_pause_frames_lo; in populate_lancer_stats()
572 drvs->rx_crc_errors = pport_stats->rx_crc_errors_lo; in populate_lancer_stats()
573 drvs->rx_control_frames = pport_stats->rx_control_frames_lo; in populate_lancer_stats()
574 drvs->rx_in_range_errors = pport_stats->rx_in_range_errors; in populate_lancer_stats()
575 drvs->rx_frame_too_long = pport_stats->rx_frames_too_long_lo; in populate_lancer_stats()
576 drvs->rx_dropped_runt = pport_stats->rx_dropped_runt; in populate_lancer_stats()
577 drvs->rx_ip_checksum_errs = pport_stats->rx_ip_checksum_errors; in populate_lancer_stats()
578 drvs->rx_tcp_checksum_errs = pport_stats->rx_tcp_checksum_errors; in populate_lancer_stats()
579 drvs->rx_udp_checksum_errs = pport_stats->rx_udp_checksum_errors; in populate_lancer_stats()
580 drvs->rx_dropped_tcp_length = in populate_lancer_stats()
581 pport_stats->rx_dropped_invalid_tcp_length; in populate_lancer_stats()
582 drvs->rx_dropped_too_small = pport_stats->rx_dropped_too_small; in populate_lancer_stats()
583 drvs->rx_dropped_too_short = pport_stats->rx_dropped_too_short; in populate_lancer_stats()
584 drvs->rx_out_range_errors = pport_stats->rx_out_of_range_errors; in populate_lancer_stats()
585 drvs->rx_dropped_header_too_small = in populate_lancer_stats()
586 pport_stats->rx_dropped_header_too_small; in populate_lancer_stats()
587 drvs->rx_input_fifo_overflow_drop = pport_stats->rx_fifo_overflow; in populate_lancer_stats()
588 drvs->rx_address_filtered = in populate_lancer_stats()
589 pport_stats->rx_address_filtered + in populate_lancer_stats()
590 pport_stats->rx_vlan_filtered; in populate_lancer_stats()
591 drvs->rx_alignment_symbol_errors = pport_stats->rx_symbol_errors_lo; in populate_lancer_stats()
592 drvs->rxpp_fifo_overflow_drop = pport_stats->rx_fifo_overflow; in populate_lancer_stats()
593 drvs->tx_pauseframes = pport_stats->tx_pause_frames_lo; in populate_lancer_stats()
594 drvs->tx_controlframes = pport_stats->tx_control_frames_lo; in populate_lancer_stats()
595 drvs->jabber_events = pport_stats->rx_jabbers; in populate_lancer_stats()
596 drvs->forwarded_packets = pport_stats->num_forwards_lo; in populate_lancer_stats()
597 drvs->rx_drops_mtu = pport_stats->rx_drops_mtu_lo; in populate_lancer_stats()
598 drvs->rx_drops_too_many_frags = in populate_lancer_stats()
599 pport_stats->rx_drops_too_many_frags_lo; in populate_lancer_stats()
618 rx_stats(rxo)->rx_drops_no_frags = erx_stat; in populate_erx_stats()
621 * 65535. Driver accumulates a 32-bit value in populate_erx_stats()
623 accumulate_16bit_val(&rx_stats(rxo)->rx_drops_no_frags, in populate_erx_stats()
647 erx_stat = erx->rx_drops_no_fragments[rxo->q.id]; in be_parse_stats()
657 struct be_drv_stats *drvs = &adapter->drv_stats; in be_get_stats64()
668 start = u64_stats_fetch_begin_irq(&rx_stats->sync); in be_get_stats64()
669 pkts = rx_stats(rxo)->rx_pkts; in be_get_stats64()
670 bytes = rx_stats(rxo)->rx_bytes; in be_get_stats64()
671 } while (u64_stats_fetch_retry_irq(&rx_stats->sync, start)); in be_get_stats64()
672 stats->rx_packets += pkts; in be_get_stats64()
673 stats->rx_bytes += bytes; in be_get_stats64()
674 stats->multicast += rx_stats(rxo)->rx_mcast_pkts; in be_get_stats64()
675 stats->rx_dropped += rx_stats(rxo)->rx_drops_no_skbs + in be_get_stats64()
676 rx_stats(rxo)->rx_drops_no_frags; in be_get_stats64()
683 start = u64_stats_fetch_begin_irq(&tx_stats->sync); in be_get_stats64()
684 pkts = tx_stats(txo)->tx_pkts; in be_get_stats64()
685 bytes = tx_stats(txo)->tx_bytes; in be_get_stats64()
686 } while (u64_stats_fetch_retry_irq(&tx_stats->sync, start)); in be_get_stats64()
687 stats->tx_packets += pkts; in be_get_stats64()
688 stats->tx_bytes += bytes; in be_get_stats64()
692 stats->rx_errors = drvs->rx_crc_errors + in be_get_stats64()
693 drvs->rx_alignment_symbol_errors + in be_get_stats64()
694 drvs->rx_in_range_errors + in be_get_stats64()
695 drvs->rx_out_range_errors + in be_get_stats64()
696 drvs->rx_frame_too_long + in be_get_stats64()
697 drvs->rx_dropped_too_small + in be_get_stats64()
698 drvs->rx_dropped_too_short + in be_get_stats64()
699 drvs->rx_dropped_header_too_small + in be_get_stats64()
700 drvs->rx_dropped_tcp_length + in be_get_stats64()
701 drvs->rx_dropped_runt; in be_get_stats64()
703 /* detailed rx errors */ in be_get_stats64()
704 stats->rx_length_errors = drvs->rx_in_range_errors + in be_get_stats64()
705 drvs->rx_out_range_errors + in be_get_stats64()
706 drvs->rx_frame_too_long; in be_get_stats64()
708 stats->rx_crc_errors = drvs->rx_crc_errors; in be_get_stats64()
711 stats->rx_frame_errors = drvs->rx_alignment_symbol_errors; in be_get_stats64()
715 stats->rx_fifo_errors = drvs->rxpp_fifo_overflow_drop + in be_get_stats64()
716 drvs->rx_input_fifo_overflow_drop + in be_get_stats64()
717 drvs->rx_drops_no_pbuf; in be_get_stats64()
722 struct net_device *netdev = adapter->netdev; in be_link_status_update()
724 if (!(adapter->flags & BE_FLAGS_LINK_STATUS_INIT)) { in be_link_status_update()
726 adapter->flags |= BE_FLAGS_LINK_STATUS_INIT; in be_link_status_update()
739 if (skb->encapsulation) in be_gso_hdr_len()
748 u32 tx_pkts = skb_shinfo(skb)->gso_segs ? : 1; in be_tx_stats_update()
750 u32 dup_hdr_len = tx_pkts > 1 ? be_gso_hdr_len(skb) * (tx_pkts - 1) : 0; in be_tx_stats_update()
752 u64_stats_update_begin(&stats->sync); in be_tx_stats_update()
753 stats->tx_reqs++; in be_tx_stats_update()
754 stats->tx_bytes += skb->len + dup_hdr_len; in be_tx_stats_update()
755 stats->tx_pkts += tx_pkts; in be_tx_stats_update()
756 if (skb->encapsulation && skb->ip_summed == CHECKSUM_PARTIAL) in be_tx_stats_update()
757 stats->tx_vxlan_offload_pkts += tx_pkts; in be_tx_stats_update()
758 u64_stats_update_end(&stats->sync); in be_tx_stats_update()
765 return 1 + (skb_headlen(skb) ? 1 : 0) + skb_shinfo(skb)->nr_frags; in skb_wrb_cnt()
770 wrb->frag_pa_hi = cpu_to_le32(upper_32_bits(addr)); in wrb_fill()
771 wrb->frag_pa_lo = cpu_to_le32(lower_32_bits(addr)); in wrb_fill()
772 wrb->frag_len = cpu_to_le32(len & ETH_WRB_FRAG_LEN_MASK); in wrb_fill()
773 wrb->rsvd0 = 0; in wrb_fill()
776 /* A dummy wrb is just all zeros. Using a separate routine for dummy-wrb
781 wrb->frag_pa_hi = 0; in wrb_fill_dummy()
782 wrb->frag_pa_lo = 0; in wrb_fill_dummy()
783 wrb->frag_len = 0; in wrb_fill_dummy()
784 wrb->rsvd0 = 0; in wrb_fill_dummy()
796 if (!(adapter->vlan_prio_bmap & (1 << vlan_prio))) in be_get_tx_vlan_tag()
798 adapter->recommended_prio_bits; in be_get_tx_vlan_tag()
806 return (inner_ip_hdr(skb)->version == 4) ? in skb_inner_ip_proto()
807 inner_ip_hdr(skb)->protocol : inner_ipv6_hdr(skb)->nexthdr; in skb_inner_ip_proto()
812 return (ip_hdr(skb)->version == 4) ? in skb_ip_proto()
813 ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr; in skb_ip_proto()
818 return atomic_read(&txo->q.used) + BE_MAX_TX_FRAG_COUNT >= txo->q.len; in be_is_txq_full()
823 return atomic_read(&txo->q.used) < txo->q.len / 2; in be_can_txq_wake()
828 return atomic_read(&txo->q.used) > txo->pend_wrb_cnt; in be_is_tx_compl_pending()
838 BE_WRB_F_SET(wrb_params->features, LSO, 1); in be_get_wrb_params_from_skb()
839 wrb_params->lso_mss = skb_shinfo(skb)->gso_size; in be_get_wrb_params_from_skb()
841 BE_WRB_F_SET(wrb_params->features, LSO6, 1); in be_get_wrb_params_from_skb()
842 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in be_get_wrb_params_from_skb()
843 if (skb->encapsulation) { in be_get_wrb_params_from_skb()
844 BE_WRB_F_SET(wrb_params->features, IPCS, 1); in be_get_wrb_params_from_skb()
850 BE_WRB_F_SET(wrb_params->features, TCPCS, 1); in be_get_wrb_params_from_skb()
852 BE_WRB_F_SET(wrb_params->features, UDPCS, 1); in be_get_wrb_params_from_skb()
856 BE_WRB_F_SET(wrb_params->features, VLAN, 1); in be_get_wrb_params_from_skb()
857 wrb_params->vlan_tag = be_get_tx_vlan_tag(adapter, skb); in be_get_wrb_params_from_skb()
860 BE_WRB_F_SET(wrb_params->features, CRC, 1); in be_get_wrb_params_from_skb()
871 BE_WRB_F_GET(wrb_params->features, CRC)); in wrb_fill_hdr()
873 BE_WRB_F_GET(wrb_params->features, IPCS)); in wrb_fill_hdr()
875 BE_WRB_F_GET(wrb_params->features, TCPCS)); in wrb_fill_hdr()
877 BE_WRB_F_GET(wrb_params->features, UDPCS)); in wrb_fill_hdr()
880 BE_WRB_F_GET(wrb_params->features, LSO)); in wrb_fill_hdr()
882 BE_WRB_F_GET(wrb_params->features, LSO6)); in wrb_fill_hdr()
883 SET_TX_WRB_HDR_BITS(lso_mss, hdr, wrb_params->lso_mss); in wrb_fill_hdr()
889 BE_WRB_F_GET(wrb_params->features, VLAN_SKIP_HW)); in wrb_fill_hdr()
891 BE_WRB_F_GET(wrb_params->features, VLAN)); in wrb_fill_hdr()
892 SET_TX_WRB_HDR_BITS(vlan_tag, hdr, wrb_params->vlan_tag); in wrb_fill_hdr()
895 SET_TX_WRB_HDR_BITS(len, hdr, skb->len); in wrb_fill_hdr()
897 BE_WRB_F_GET(wrb_params->features, OS2BMC)); in wrb_fill_hdr()
904 u32 frag_len = le32_to_cpu(wrb->frag_len); in unmap_tx_frag()
907 dma = (u64)le32_to_cpu(wrb->frag_pa_hi) << 32 | in unmap_tx_frag()
908 (u64)le32_to_cpu(wrb->frag_pa_lo); in unmap_tx_frag()
920 u32 head = txo->q.head; in be_tx_get_wrb_hdr()
922 queue_head_inc(&txo->q); in be_tx_get_wrb_hdr()
933 struct be_queue_info *txq = &txo->q; in be_tx_setup_wrb_hdr()
939 BUG_ON(txo->sent_skb_list[head]); in be_tx_setup_wrb_hdr()
940 txo->sent_skb_list[head] = skb; in be_tx_setup_wrb_hdr()
941 txo->last_req_hdr = head; in be_tx_setup_wrb_hdr()
942 atomic_add(num_frags, &txq->used); in be_tx_setup_wrb_hdr()
943 txo->last_req_wrb_cnt = num_frags; in be_tx_setup_wrb_hdr()
944 txo->pend_wrb_cnt += num_frags; in be_tx_setup_wrb_hdr()
952 struct be_queue_info *txq = &txo->q; in be_tx_setup_wrb_frag()
969 struct be_queue_info *txq = &txo->q; in be_xmit_restore()
971 dev = &adapter->pdev->dev; in be_xmit_restore()
972 txq->head = head; in be_xmit_restore()
980 copied -= le32_to_cpu(wrb->frag_len); in be_xmit_restore()
984 txq->head = head; in be_xmit_restore()
996 struct device *dev = &adapter->pdev->dev; in be_xmit_enqueue()
1004 if (skb->len > skb->data_len) { in be_xmit_enqueue()
1007 busaddr = dma_map_single(dev, skb->data, len, DMA_TO_DEVICE); in be_xmit_enqueue()
1015 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in be_xmit_enqueue()
1016 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in be_xmit_enqueue()
1032 adapter->drv_stats.dma_map_errors++; in be_xmit_enqueue()
1039 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; in qnq_async_evt_rcvd()
1059 if (qnq_async_evt_rcvd(adapter) && adapter->pvid) { in be_insert_vlan_in_pkt()
1061 vlan_tag = adapter->pvid; in be_insert_vlan_in_pkt()
1067 BE_WRB_F_SET(wrb_params->features, VLAN_SKIP_HW, 1); in be_insert_vlan_in_pkt()
1079 if (adapter->qnq_vid) { in be_insert_vlan_in_pkt()
1080 vlan_tag = adapter->qnq_vid; in be_insert_vlan_in_pkt()
1085 BE_WRB_F_SET(wrb_params->features, VLAN_SKIP_HW, 1); in be_insert_vlan_in_pkt()
1093 struct ethhdr *eh = (struct ethhdr *)skb->data; in be_ipv6_exthdr_check()
1096 if (eh->h_proto == htons(ETH_P_IPV6)) { in be_ipv6_exthdr_check()
1097 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + offset); in be_ipv6_exthdr_check()
1100 if (ip6h->nexthdr != NEXTHDR_TCP && in be_ipv6_exthdr_check()
1101 ip6h->nexthdr != NEXTHDR_UDP) { in be_ipv6_exthdr_check()
1103 (struct ipv6_opt_hdr *)(skb->data + offset); in be_ipv6_exthdr_check()
1106 if (ehdr->hdrlen == 0xff) in be_ipv6_exthdr_check()
1115 return skb_vlan_tag_present(skb) || adapter->pvid || adapter->qnq_vid; in be_vlan_tag_tx_chk()
1128 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; in be_lancer_xmit_workarounds()
1136 eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ? in be_lancer_xmit_workarounds()
1138 if (skb->len <= 60 && in be_lancer_xmit_workarounds()
1142 pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len)); in be_lancer_xmit_workarounds()
1146 * tagging in pvid-tagging mode in be_lancer_xmit_workarounds()
1149 veh->h_vlan_proto == htons(ETH_P_8021Q)) in be_lancer_xmit_workarounds()
1150 BE_WRB_F_SET(wrb_params->features, VLAN_SKIP_HW, 1); in be_lancer_xmit_workarounds()
1156 if (skb->ip_summed != CHECKSUM_PARTIAL && in be_lancer_xmit_workarounds()
1168 (adapter->pvid || adapter->qnq_vid) && in be_lancer_xmit_workarounds()
1203 if (skb->len <= 32) { in be_xmit_workarounds()
1217 WARN_ON_ONCE(skb->len > BE_MAX_GSO_SIZE); in be_xmit_workarounds()
1226 struct be_queue_info *txq = &txo->q; in be_xmit_flush()
1227 struct be_eth_hdr_wrb *hdr = queue_index_node(txq, txo->last_req_hdr); in be_xmit_flush()
1230 if (!(hdr->dw[2] & cpu_to_le32(TX_HDR_WRB_EVT))) in be_xmit_flush()
1231 hdr->dw[2] |= cpu_to_le32(TX_HDR_WRB_EVT | TX_HDR_WRB_COMPL); in be_xmit_flush()
1234 if (!lancer_chip(adapter) && (txo->pend_wrb_cnt & 1)) { in be_xmit_flush()
1237 atomic_inc(&txq->used); in be_xmit_flush()
1238 txo->pend_wrb_cnt++; in be_xmit_flush()
1239 hdr->dw[2] &= ~cpu_to_le32(TX_HDR_WRB_NUM_MASK << in be_xmit_flush()
1241 hdr->dw[2] |= cpu_to_le32((txo->last_req_wrb_cnt + 1) << in be_xmit_flush()
1244 be_txq_notify(adapter, txo, txo->pend_wrb_cnt); in be_xmit_flush()
1245 txo->pend_wrb_cnt = 0; in be_xmit_flush()
1258 is_multicast_ether_addr(eh->h_dest) && \
1259 !is_broadcast_ether_addr(eh->h_dest))
1263 is_broadcast_ether_addr(eh->h_dest))
1268 #define is_arp(skb) (skb->protocol == htons(ETH_P_ARP))
1271 (adapter->bmc_filt_mask & (BMC_FILT_BROADCAST_ARP))
1274 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_CLIENT)
1277 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_DHCP_SERVER)
1280 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST_NET_BIOS)
1283 (adapter->bmc_filt_mask & \
1287 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RA)
1290 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST_IPV6_RAS)
1293 (adapter->bmc_filt_mask & BMC_FILT_BROADCAST)
1296 (adapter->bmc_filt_mask & BMC_FILT_MULTICAST)
1301 struct ethhdr *eh = (struct ethhdr *)(*skb)->data; in be_send_pkt_to_bmc()
1307 if (!is_multicast_ether_addr(eh->h_dest)) in be_send_pkt_to_bmc()
1317 if ((*skb)->protocol == htons(ETH_P_IPV6)) { in be_send_pkt_to_bmc()
1319 u8 nexthdr = hdr->nexthdr; in be_send_pkt_to_bmc()
1324 switch (icmp6->icmp6_type) { in be_send_pkt_to_bmc()
1340 switch (ntohs(udp->dest)) { in be_send_pkt_to_bmc()
1372 struct be_tx_obj *txo = &adapter->tx_obj[q_idx]; in be_xmit()
1403 tx_stats(txo)->tx_stops++; in be_xmit()
1411 tx_stats(txo)->tx_drv_drops++; in be_xmit()
1413 if (flush && txo->pend_wrb_cnt) in be_xmit()
1422 struct device *dev = &adapter->pdev->dev; in be_tx_timeout()
1433 i, txo->q.head, txo->q.tail, in be_tx_timeout()
1434 atomic_read(&txo->q.used), txo->q.id); in be_tx_timeout()
1436 entry = txo->q.dma_mem.va; in be_tx_timeout()
1446 entry = txo->cq.dma_mem.va; in be_tx_timeout()
1448 i, txo->cq.head, txo->cq.tail, in be_tx_timeout()
1449 atomic_read(&txo->cq.used)); in be_tx_timeout()
1460 if (txo->sent_skb_list[j]) { in be_tx_timeout()
1461 skb = txo->sent_skb_list[j]; in be_tx_timeout()
1462 if (ip_hdr(skb)->protocol == IPPROTO_TCP) { in be_tx_timeout()
1465 ntohs(tcphdr->source)); in be_tx_timeout()
1467 ntohs(tcphdr->dest)); in be_tx_timeout()
1469 ntohs(tcphdr->seq)); in be_tx_timeout()
1471 ntohs(tcphdr->ack_seq)); in be_tx_timeout()
1472 } else if (ip_hdr(skb)->protocol == in be_tx_timeout()
1476 ntohs(udphdr->source)); in be_tx_timeout()
1478 ntohs(udphdr->dest)); in be_tx_timeout()
1481 j, skb, skb->len, skb->protocol); in be_tx_timeout()
1498 return (adapter->if_flags & BE_IF_FLAGS_ALL_PROMISCUOUS) == in be_in_all_promisc()
1504 struct device *dev = &adapter->pdev->dev; in be_set_vlan_promisc()
1507 if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) in be_set_vlan_promisc()
1513 adapter->if_flags |= BE_IF_FLAGS_VLAN_PROMISCUOUS; in be_set_vlan_promisc()
1522 struct device *dev = &adapter->pdev->dev; in be_clear_vlan_promisc()
1528 adapter->if_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS; in be_clear_vlan_promisc()
1539 struct device *dev = &adapter->pdev->dev; in be_vid_config()
1545 if (adapter->netdev->flags & IFF_PROMISC) in be_vid_config()
1548 if (adapter->vlans_added > be_max_vlans(adapter)) in be_vid_config()
1551 if (adapter->if_flags & BE_IF_FLAGS_VLAN_PROMISCUOUS) { in be_vid_config()
1557 for_each_set_bit(i, adapter->vids, VLAN_N_VID) in be_vid_config()
1560 status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0); in be_vid_config()
1577 mutex_lock(&adapter->rx_filter_lock); in be_vlan_add_vid()
1583 if (test_bit(vid, adapter->vids)) in be_vlan_add_vid()
1586 set_bit(vid, adapter->vids); in be_vlan_add_vid()
1587 adapter->vlans_added++; in be_vlan_add_vid()
1591 mutex_unlock(&adapter->rx_filter_lock); in be_vlan_add_vid()
1600 mutex_lock(&adapter->rx_filter_lock); in be_vlan_rem_vid()
1606 if (!test_bit(vid, adapter->vids)) in be_vlan_rem_vid()
1609 clear_bit(vid, adapter->vids); in be_vlan_rem_vid()
1610 adapter->vlans_added--; in be_vlan_rem_vid()
1614 mutex_unlock(&adapter->rx_filter_lock); in be_vlan_rem_vid()
1621 adapter->if_flags |= BE_IF_FLAGS_ALL_PROMISCUOUS; in be_set_all_promisc()
1628 if (adapter->if_flags & BE_IF_FLAGS_MCAST_PROMISCUOUS) in be_set_mc_promisc()
1633 adapter->if_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS; in be_set_mc_promisc()
1640 if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS) in be_set_uc_promisc()
1645 adapter->if_flags |= BE_IF_FLAGS_PROMISCUOUS; in be_set_uc_promisc()
1652 if (!(adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS)) in be_clear_uc_promisc()
1657 adapter->if_flags &= ~BE_IF_FLAGS_PROMISCUOUS; in be_clear_uc_promisc()
1670 adapter->update_uc_list = true; in be_uc_list_update()
1679 adapter->update_mc_list = true; in be_mc_list_update()
1685 struct net_device *netdev = adapter->netdev; in be_set_mc_list()
1693 if (netdev->flags & IFF_PROMISC) { in be_set_mc_list()
1694 adapter->update_mc_list = false; in be_set_mc_list()
1695 } else if (netdev->flags & IFF_ALLMULTI || in be_set_mc_list()
1701 adapter->update_mc_list = false; in be_set_mc_list()
1702 } else if (adapter->if_flags & BE_IF_FLAGS_MCAST_PROMISCUOUS) { in be_set_mc_list()
1703 /* Update mc-list unconditionally if the iface was previously in be_set_mc_list()
1704 * in mc-promisc mode and now is out of that mode. in be_set_mc_list()
1706 adapter->update_mc_list = true; in be_set_mc_list()
1709 if (adapter->update_mc_list) { in be_set_mc_list()
1712 /* cache the mc-list in adapter */ in be_set_mc_list()
1714 ether_addr_copy(adapter->mc_list[i].mac, ha->addr); in be_set_mc_list()
1717 adapter->mc_count = netdev_mc_count(netdev); in be_set_mc_list()
1723 } else if (adapter->update_mc_list) { in be_set_mc_list()
1726 adapter->if_flags &= ~BE_IF_FLAGS_MCAST_PROMISCUOUS; in be_set_mc_list()
1730 adapter->update_mc_list = false; in be_set_mc_list()
1736 struct net_device *netdev = adapter->netdev; in be_clear_mc_list()
1740 adapter->mc_count = 0; in be_clear_mc_list()
1745 if (ether_addr_equal(adapter->uc_list[uc_idx].mac, adapter->dev_mac)) { in be_uc_mac_add()
1746 adapter->pmac_id[uc_idx + 1] = adapter->pmac_id[0]; in be_uc_mac_add()
1750 return be_cmd_pmac_add(adapter, adapter->uc_list[uc_idx].mac, in be_uc_mac_add()
1751 adapter->if_handle, in be_uc_mac_add()
1752 &adapter->pmac_id[uc_idx + 1], 0); in be_uc_mac_add()
1757 if (pmac_id == adapter->pmac_id[0]) in be_uc_mac_del()
1760 be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0); in be_uc_mac_del()
1765 struct net_device *netdev = adapter->netdev; in be_set_uc_list()
1773 if (netdev->flags & IFF_PROMISC) { in be_set_uc_list()
1774 adapter->update_uc_list = false; in be_set_uc_list()
1775 } else if (netdev_uc_count(netdev) > (be_max_uc(adapter) - 1)) { in be_set_uc_list()
1777 adapter->update_uc_list = false; in be_set_uc_list()
1778 } else if (adapter->if_flags & BE_IF_FLAGS_PROMISCUOUS) { in be_set_uc_list()
1779 /* Update uc-list unconditionally if the iface was previously in be_set_uc_list()
1780 * in uc-promisc mode and now is out of that mode. in be_set_uc_list()
1782 adapter->update_uc_list = true; in be_set_uc_list()
1785 if (adapter->update_uc_list) { in be_set_uc_list()
1786 /* cache the uc-list in adapter array */ in be_set_uc_list()
1789 ether_addr_copy(adapter->uc_list[i].mac, ha->addr); in be_set_uc_list()
1798 } else if (adapter->update_uc_list) { in be_set_uc_list()
1801 for (i = 0; i < adapter->uc_macs; i++) in be_set_uc_list()
1802 be_uc_mac_del(adapter, adapter->pmac_id[i + 1]); in be_set_uc_list()
1806 adapter->uc_macs = curr_uc_macs; in be_set_uc_list()
1807 adapter->update_uc_list = false; in be_set_uc_list()
1813 struct net_device *netdev = adapter->netdev; in be_clear_uc_list()
1817 for (i = 0; i < adapter->uc_macs; i++) in be_clear_uc_list()
1818 be_uc_mac_del(adapter, adapter->pmac_id[i + 1]); in be_clear_uc_list()
1820 adapter->uc_macs = 0; in be_clear_uc_list()
1825 struct net_device *netdev = adapter->netdev; in __be_set_rx_mode()
1827 mutex_lock(&adapter->rx_filter_lock); in __be_set_rx_mode()
1829 if (netdev->flags & IFF_PROMISC) { in __be_set_rx_mode()
1833 /* We need to re-program the vlan-list or clear in __be_set_rx_mode()
1834 * vlan-promisc mode (if needed) when the interface in __be_set_rx_mode()
1843 mutex_unlock(&adapter->rx_filter_lock); in __be_set_rx_mode()
1851 __be_set_rx_mode(cmd_work->adapter); in be_work_set_rx_mode()
1858 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_mac()
1862 return -EPERM; in be_set_vf_mac()
1864 if (!is_valid_ether_addr(mac) || vf >= adapter->num_vfs) in be_set_vf_mac()
1865 return -EINVAL; in be_set_vf_mac()
1870 if (ether_addr_equal(mac, vf_cfg->mac_addr)) in be_set_vf_mac()
1874 be_cmd_pmac_del(adapter, vf_cfg->if_handle, vf_cfg->pmac_id, in be_set_vf_mac()
1877 status = be_cmd_pmac_add(adapter, mac, vf_cfg->if_handle, in be_set_vf_mac()
1878 &vf_cfg->pmac_id, vf + 1); in be_set_vf_mac()
1880 status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle, in be_set_vf_mac()
1885 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed: %#x", in be_set_vf_mac()
1890 ether_addr_copy(vf_cfg->mac_addr, mac); in be_set_vf_mac()
1899 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_get_vf_config()
1902 return -EPERM; in be_get_vf_config()
1904 if (vf >= adapter->num_vfs) in be_get_vf_config()
1905 return -EINVAL; in be_get_vf_config()
1907 vi->vf = vf; in be_get_vf_config()
1908 vi->max_tx_rate = vf_cfg->tx_rate; in be_get_vf_config()
1909 vi->min_tx_rate = 0; in be_get_vf_config()
1910 vi->vlan = vf_cfg->vlan_tag & VLAN_VID_MASK; in be_get_vf_config()
1911 vi->qos = vf_cfg->vlan_tag >> VLAN_PRIO_SHIFT; in be_get_vf_config()
1912 memcpy(&vi->mac, vf_cfg->mac_addr, ETH_ALEN); in be_get_vf_config()
1913 vi->linkstate = adapter->vf_cfg[vf].plink_tracking; in be_get_vf_config()
1914 vi->spoofchk = adapter->vf_cfg[vf].spoofchk; in be_get_vf_config()
1921 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_tvt()
1923 int vf_if_id = vf_cfg->if_handle; in be_set_vf_tvt()
1931 /* Clear pre-programmed VLAN filters on VF if any, if TVT is enabled */ in be_set_vf_tvt()
1935 dev_info(&adapter->pdev->dev, in be_set_vf_tvt()
1939 if (vf_cfg->privileges & BE_PRIV_FILTMGMT) { in be_set_vf_tvt()
1940 status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges & in be_set_vf_tvt()
1943 vf_cfg->privileges &= ~BE_PRIV_FILTMGMT; in be_set_vf_tvt()
1950 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_clear_vf_tvt()
1951 struct device *dev = &adapter->pdev->dev; in be_clear_vf_tvt()
1956 vf_cfg->if_handle, 0, 0); in be_clear_vf_tvt()
1961 if (!(vf_cfg->privileges & BE_PRIV_FILTMGMT)) { in be_clear_vf_tvt()
1962 status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges | in be_clear_vf_tvt()
1965 vf_cfg->privileges |= BE_PRIV_FILTMGMT; in be_clear_vf_tvt()
1971 "Disable/re-enable i/f in VM to clear Transparent VLAN tag"); in be_clear_vf_tvt()
1979 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_vlan()
1983 return -EPERM; in be_set_vf_vlan()
1985 if (vf >= adapter->num_vfs || vlan > 4095 || qos > 7) in be_set_vf_vlan()
1986 return -EINVAL; in be_set_vf_vlan()
1989 return -EPROTONOSUPPORT; in be_set_vf_vlan()
1999 dev_err(&adapter->pdev->dev, in be_set_vf_vlan()
2005 vf_cfg->vlan_tag = vlan; in be_set_vf_vlan()
2013 struct device *dev = &adapter->pdev->dev; in be_set_vf_tx_rate()
2019 return -EPERM; in be_set_vf_tx_rate()
2021 if (vf >= adapter->num_vfs) in be_set_vf_tx_rate()
2022 return -EINVAL; in be_set_vf_tx_rate()
2025 return -EINVAL; in be_set_vf_tx_rate()
2036 dev_err(dev, "TX-rate setting not allowed when link is down\n"); in be_set_vf_tx_rate()
2037 status = -ENETDOWN; in be_set_vf_tx_rate()
2042 dev_err(dev, "TX-rate must be between 100 and %d Mbps\n", in be_set_vf_tx_rate()
2044 status = -EINVAL; in be_set_vf_tx_rate()
2051 dev_err(dev, "TX-rate must be a multiple of %d Mbps\n", in be_set_vf_tx_rate()
2053 status = -EINVAL; in be_set_vf_tx_rate()
2062 adapter->vf_cfg[vf].tx_rate = max_tx_rate; in be_set_vf_tx_rate()
2066 dev_err(dev, "TX-rate setting of %dMbps on VF%d failed\n", in be_set_vf_tx_rate()
2078 return -EPERM; in be_set_vf_link_state()
2080 if (vf >= adapter->num_vfs) in be_set_vf_link_state()
2081 return -EINVAL; in be_set_vf_link_state()
2085 dev_err(&adapter->pdev->dev, in be_set_vf_link_state()
2090 adapter->vf_cfg[vf].plink_tracking = link_state; in be_set_vf_link_state()
2098 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; in be_set_vf_spoofchk()
2103 return -EPERM; in be_set_vf_spoofchk()
2105 if (vf >= adapter->num_vfs) in be_set_vf_spoofchk()
2106 return -EINVAL; in be_set_vf_spoofchk()
2109 return -EOPNOTSUPP; in be_set_vf_spoofchk()
2111 if (enable == vf_cfg->spoofchk) in be_set_vf_spoofchk()
2116 status = be_cmd_set_hsw_config(adapter, 0, vf + 1, vf_cfg->if_handle, in be_set_vf_spoofchk()
2119 dev_err(&adapter->pdev->dev, in be_set_vf_spoofchk()
2124 vf_cfg->spoofchk = enable; in be_set_vf_spoofchk()
2131 aic->rx_pkts_prev = rx_pkts; in be_aic_update()
2132 aic->tx_reqs_prev = tx_pkts; in be_aic_update()
2133 aic->jiffies = now; in be_aic_update()
2138 struct be_adapter *adapter = eqo->adapter; in be_get_new_eqd()
2148 aic = &adapter->aic_obj[eqo->idx]; in be_get_new_eqd()
2149 if (!adapter->aic_enabled) { in be_get_new_eqd()
2150 if (aic->jiffies) in be_get_new_eqd()
2151 aic->jiffies = 0; in be_get_new_eqd()
2152 eqd = aic->et_eqd; in be_get_new_eqd()
2158 start = u64_stats_fetch_begin_irq(&rxo->stats.sync); in be_get_new_eqd()
2159 rx_pkts += rxo->stats.rx_pkts; in be_get_new_eqd()
2160 } while (u64_stats_fetch_retry_irq(&rxo->stats.sync, start)); in be_get_new_eqd()
2165 start = u64_stats_fetch_begin_irq(&txo->stats.sync); in be_get_new_eqd()
2166 tx_pkts += txo->stats.tx_reqs; in be_get_new_eqd()
2167 } while (u64_stats_fetch_retry_irq(&txo->stats.sync, start)); in be_get_new_eqd()
2172 if (!aic->jiffies || time_before(now, aic->jiffies) || in be_get_new_eqd()
2173 rx_pkts < aic->rx_pkts_prev || in be_get_new_eqd()
2174 tx_pkts < aic->tx_reqs_prev) { in be_get_new_eqd()
2176 return aic->prev_eqd; in be_get_new_eqd()
2179 delta = jiffies_to_msecs(now - aic->jiffies); in be_get_new_eqd()
2181 return aic->prev_eqd; in be_get_new_eqd()
2183 pps = (((u32)(rx_pkts - aic->rx_pkts_prev) * 1000) / delta) + in be_get_new_eqd()
2184 (((u32)(tx_pkts - aic->tx_reqs_prev) * 1000) / delta); in be_get_new_eqd()
2189 eqd = min_t(u32, eqd, aic->max_eqd); in be_get_new_eqd()
2190 eqd = max_t(u32, eqd, aic->min_eqd); in be_get_new_eqd()
2197 /* For Skyhawk-R only */
2200 struct be_adapter *adapter = eqo->adapter; in be_get_eq_delay_mult_enc()
2201 struct be_aic_obj *aic = &adapter->aic_obj[eqo->idx]; in be_get_eq_delay_mult_enc()
2206 if (!adapter->aic_enabled) in be_get_eq_delay_mult_enc()
2209 if (jiffies_to_msecs(now - aic->jiffies) < 1) in be_get_eq_delay_mult_enc()
2210 eqd = aic->prev_eqd; in be_get_eq_delay_mult_enc()
2223 aic->prev_eqd = eqd; in be_get_eq_delay_mult_enc()
2236 aic = &adapter->aic_obj[eqo->idx]; in be_eqd_update()
2238 if (force_update || eqd != aic->prev_eqd) { in be_eqd_update()
2240 set_eqd[num].eq_id = eqo->q.id; in be_eqd_update()
2241 aic->prev_eqd = eqd; in be_eqd_update()
2255 u64_stats_update_begin(&stats->sync); in be_rx_stats_update()
2256 stats->rx_compl++; in be_rx_stats_update()
2257 stats->rx_bytes += rxcp->pkt_size; in be_rx_stats_update()
2258 stats->rx_pkts++; in be_rx_stats_update()
2259 if (rxcp->tunneled) in be_rx_stats_update()
2260 stats->rx_vxlan_offload_pkts++; in be_rx_stats_update()
2261 if (rxcp->pkt_type == BE_MULTICAST_PACKET) in be_rx_stats_update()
2262 stats->rx_mcast_pkts++; in be_rx_stats_update()
2263 if (rxcp->err) in be_rx_stats_update()
2264 stats->rx_compl_err++; in be_rx_stats_update()
2265 u64_stats_update_end(&stats->sync); in be_rx_stats_update()
2273 return (rxcp->tcpf || rxcp->udpf) && rxcp->l4_csum && in csum_passed()
2274 (rxcp->ip_csum || rxcp->ipv6) && !rxcp->err; in csum_passed()
2279 struct be_adapter *adapter = rxo->adapter; in get_rx_page_info()
2281 struct be_queue_info *rxq = &rxo->q; in get_rx_page_info()
2282 u32 frag_idx = rxq->tail; in get_rx_page_info()
2284 rx_page_info = &rxo->page_info_tbl[frag_idx]; in get_rx_page_info()
2285 BUG_ON(!rx_page_info->page); in get_rx_page_info()
2287 if (rx_page_info->last_frag) { in get_rx_page_info()
2288 dma_unmap_page(&adapter->pdev->dev, in get_rx_page_info()
2290 adapter->big_page_size, DMA_FROM_DEVICE); in get_rx_page_info()
2291 rx_page_info->last_frag = false; in get_rx_page_info()
2293 dma_sync_single_for_cpu(&adapter->pdev->dev, in get_rx_page_info()
2299 atomic_dec(&rxq->used); in get_rx_page_info()
2303 /* Throwaway the data in the Rx completion */
2308 u16 i, num_rcvd = rxcp->num_rcvd; in be_rx_compl_discard()
2312 put_page(page_info->page); in be_rx_compl_discard()
2330 start = page_address(page_info->page) + page_info->page_offset; in skb_fill_rx_data()
2334 curr_frag_len = min(rxcp->pkt_size, rx_frag_size); in skb_fill_rx_data()
2336 skb->len = curr_frag_len; in skb_fill_rx_data()
2338 memcpy(skb->data, start, curr_frag_len); in skb_fill_rx_data()
2340 put_page(page_info->page); in skb_fill_rx_data()
2341 skb->data_len = 0; in skb_fill_rx_data()
2342 skb->tail += curr_frag_len; in skb_fill_rx_data()
2345 memcpy(skb->data, start, hdr_len); in skb_fill_rx_data()
2346 skb_shinfo(skb)->nr_frags = 1; in skb_fill_rx_data()
2347 skb_frag_set_page(skb, 0, page_info->page); in skb_fill_rx_data()
2348 skb_frag_off_set(&skb_shinfo(skb)->frags[0], in skb_fill_rx_data()
2349 page_info->page_offset + hdr_len); in skb_fill_rx_data()
2350 skb_frag_size_set(&skb_shinfo(skb)->frags[0], in skb_fill_rx_data()
2351 curr_frag_len - hdr_len); in skb_fill_rx_data()
2352 skb->data_len = curr_frag_len - hdr_len; in skb_fill_rx_data()
2353 skb->truesize += rx_frag_size; in skb_fill_rx_data()
2354 skb->tail += hdr_len; in skb_fill_rx_data()
2356 page_info->page = NULL; in skb_fill_rx_data()
2358 if (rxcp->pkt_size <= rx_frag_size) { in skb_fill_rx_data()
2359 BUG_ON(rxcp->num_rcvd != 1); in skb_fill_rx_data()
2364 remaining = rxcp->pkt_size - curr_frag_len; in skb_fill_rx_data()
2365 for (i = 1, j = 0; i < rxcp->num_rcvd; i++) { in skb_fill_rx_data()
2370 if (page_info->page_offset == 0) { in skb_fill_rx_data()
2373 skb_frag_set_page(skb, j, page_info->page); in skb_fill_rx_data()
2374 skb_frag_off_set(&skb_shinfo(skb)->frags[j], in skb_fill_rx_data()
2375 page_info->page_offset); in skb_fill_rx_data()
2376 skb_frag_size_set(&skb_shinfo(skb)->frags[j], 0); in skb_fill_rx_data()
2377 skb_shinfo(skb)->nr_frags++; in skb_fill_rx_data()
2379 put_page(page_info->page); in skb_fill_rx_data()
2382 skb_frag_size_add(&skb_shinfo(skb)->frags[j], curr_frag_len); in skb_fill_rx_data()
2383 skb->len += curr_frag_len; in skb_fill_rx_data()
2384 skb->data_len += curr_frag_len; in skb_fill_rx_data()
2385 skb->truesize += rx_frag_size; in skb_fill_rx_data()
2386 remaining -= curr_frag_len; in skb_fill_rx_data()
2387 page_info->page = NULL; in skb_fill_rx_data()
2392 /* Process the RX completion indicated by rxcp when GRO is disabled */
2396 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_process()
2397 struct net_device *netdev = adapter->netdev; in be_rx_compl_process()
2402 rx_stats(rxo)->rx_drops_no_skbs++; in be_rx_compl_process()
2409 if (likely((netdev->features & NETIF_F_RXCSUM) && csum_passed(rxcp))) in be_rx_compl_process()
2410 skb->ip_summed = CHECKSUM_UNNECESSARY; in be_rx_compl_process()
2414 skb->protocol = eth_type_trans(skb, netdev); in be_rx_compl_process()
2415 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); in be_rx_compl_process()
2416 if (netdev->features & NETIF_F_RXHASH) in be_rx_compl_process()
2417 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3); in be_rx_compl_process()
2419 skb->csum_level = rxcp->tunneled; in be_rx_compl_process()
2422 if (rxcp->vlanf) in be_rx_compl_process()
2423 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag); in be_rx_compl_process()
2428 /* Process the RX completion indicated by rxcp when GRO is enabled */
2433 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_process_gro()
2445 remaining = rxcp->pkt_size; in be_rx_compl_process_gro()
2446 for (i = 0, j = -1; i < rxcp->num_rcvd; i++) { in be_rx_compl_process_gro()
2452 if (i == 0 || page_info->page_offset == 0) { in be_rx_compl_process_gro()
2455 skb_frag_set_page(skb, j, page_info->page); in be_rx_compl_process_gro()
2456 skb_frag_off_set(&skb_shinfo(skb)->frags[j], in be_rx_compl_process_gro()
2457 page_info->page_offset); in be_rx_compl_process_gro()
2458 skb_frag_size_set(&skb_shinfo(skb)->frags[j], 0); in be_rx_compl_process_gro()
2460 put_page(page_info->page); in be_rx_compl_process_gro()
2462 skb_frag_size_add(&skb_shinfo(skb)->frags[j], curr_frag_len); in be_rx_compl_process_gro()
2463 skb->truesize += rx_frag_size; in be_rx_compl_process_gro()
2464 remaining -= curr_frag_len; in be_rx_compl_process_gro()
2469 skb_shinfo(skb)->nr_frags = j + 1; in be_rx_compl_process_gro()
2470 skb->len = rxcp->pkt_size; in be_rx_compl_process_gro()
2471 skb->data_len = rxcp->pkt_size; in be_rx_compl_process_gro()
2472 skb->ip_summed = CHECKSUM_UNNECESSARY; in be_rx_compl_process_gro()
2473 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); in be_rx_compl_process_gro()
2474 if (adapter->netdev->features & NETIF_F_RXHASH) in be_rx_compl_process_gro()
2475 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3); in be_rx_compl_process_gro()
2477 skb->csum_level = rxcp->tunneled; in be_rx_compl_process_gro()
2479 if (rxcp->vlanf) in be_rx_compl_process_gro()
2480 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag); in be_rx_compl_process_gro()
2488 rxcp->pkt_size = GET_RX_COMPL_V1_BITS(pktsize, compl); in be_parse_rx_compl_v1()
2489 rxcp->vlanf = GET_RX_COMPL_V1_BITS(vtp, compl); in be_parse_rx_compl_v1()
2490 rxcp->err = GET_RX_COMPL_V1_BITS(err, compl); in be_parse_rx_compl_v1()
2491 rxcp->tcpf = GET_RX_COMPL_V1_BITS(tcpf, compl); in be_parse_rx_compl_v1()
2492 rxcp->udpf = GET_RX_COMPL_V1_BITS(udpf, compl); in be_parse_rx_compl_v1()
2493 rxcp->ip_csum = GET_RX_COMPL_V1_BITS(ipcksm, compl); in be_parse_rx_compl_v1()
2494 rxcp->l4_csum = GET_RX_COMPL_V1_BITS(l4_cksm, compl); in be_parse_rx_compl_v1()
2495 rxcp->ipv6 = GET_RX_COMPL_V1_BITS(ip_version, compl); in be_parse_rx_compl_v1()
2496 rxcp->num_rcvd = GET_RX_COMPL_V1_BITS(numfrags, compl); in be_parse_rx_compl_v1()
2497 rxcp->pkt_type = GET_RX_COMPL_V1_BITS(cast_enc, compl); in be_parse_rx_compl_v1()
2498 rxcp->rss_hash = GET_RX_COMPL_V1_BITS(rsshash, compl); in be_parse_rx_compl_v1()
2499 if (rxcp->vlanf) { in be_parse_rx_compl_v1()
2500 rxcp->qnq = GET_RX_COMPL_V1_BITS(qnq, compl); in be_parse_rx_compl_v1()
2501 rxcp->vlan_tag = GET_RX_COMPL_V1_BITS(vlan_tag, compl); in be_parse_rx_compl_v1()
2503 rxcp->port = GET_RX_COMPL_V1_BITS(port, compl); in be_parse_rx_compl_v1()
2504 rxcp->tunneled = in be_parse_rx_compl_v1()
2511 rxcp->pkt_size = GET_RX_COMPL_V0_BITS(pktsize, compl); in be_parse_rx_compl_v0()
2512 rxcp->vlanf = GET_RX_COMPL_V0_BITS(vtp, compl); in be_parse_rx_compl_v0()
2513 rxcp->err = GET_RX_COMPL_V0_BITS(err, compl); in be_parse_rx_compl_v0()
2514 rxcp->tcpf = GET_RX_COMPL_V0_BITS(tcpf, compl); in be_parse_rx_compl_v0()
2515 rxcp->udpf = GET_RX_COMPL_V0_BITS(udpf, compl); in be_parse_rx_compl_v0()
2516 rxcp->ip_csum = GET_RX_COMPL_V0_BITS(ipcksm, compl); in be_parse_rx_compl_v0()
2517 rxcp->l4_csum = GET_RX_COMPL_V0_BITS(l4_cksm, compl); in be_parse_rx_compl_v0()
2518 rxcp->ipv6 = GET_RX_COMPL_V0_BITS(ip_version, compl); in be_parse_rx_compl_v0()
2519 rxcp->num_rcvd = GET_RX_COMPL_V0_BITS(numfrags, compl); in be_parse_rx_compl_v0()
2520 rxcp->pkt_type = GET_RX_COMPL_V0_BITS(cast_enc, compl); in be_parse_rx_compl_v0()
2521 rxcp->rss_hash = GET_RX_COMPL_V0_BITS(rsshash, compl); in be_parse_rx_compl_v0()
2522 if (rxcp->vlanf) { in be_parse_rx_compl_v0()
2523 rxcp->qnq = GET_RX_COMPL_V0_BITS(qnq, compl); in be_parse_rx_compl_v0()
2524 rxcp->vlan_tag = GET_RX_COMPL_V0_BITS(vlan_tag, compl); in be_parse_rx_compl_v0()
2526 rxcp->port = GET_RX_COMPL_V0_BITS(port, compl); in be_parse_rx_compl_v0()
2527 rxcp->ip_frag = GET_RX_COMPL_V0_BITS(ip_frag, compl); in be_parse_rx_compl_v0()
2532 struct be_eth_rx_compl *compl = queue_tail_node(&rxo->cq); in be_rx_compl_get()
2533 struct be_rx_compl_info *rxcp = &rxo->rxcp; in be_rx_compl_get()
2534 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_get()
2537 * valid bit is at the same position in both v0 and v1 Rx compl */ in be_rx_compl_get()
2538 if (compl->dw[offsetof(struct amap_eth_rx_compl_v1, valid) / 32] == 0) in be_rx_compl_get()
2544 if (adapter->be3_native) in be_rx_compl_get()
2549 if (rxcp->ip_frag) in be_rx_compl_get()
2550 rxcp->l4_csum = 0; in be_rx_compl_get()
2552 if (rxcp->vlanf) { in be_rx_compl_get()
2554 * tagged only with the transparent outer vlan-tag and must in be_rx_compl_get()
2557 if (be_is_qnq_mode(adapter) && !rxcp->qnq) in be_rx_compl_get()
2558 rxcp->vlanf = 0; in be_rx_compl_get()
2561 rxcp->vlan_tag = swab16(rxcp->vlan_tag); in be_rx_compl_get()
2563 if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) && in be_rx_compl_get()
2564 !test_bit(rxcp->vlan_tag, adapter->vids)) in be_rx_compl_get()
2565 rxcp->vlanf = 0; in be_rx_compl_get()
2569 compl->dw[offsetof(struct amap_eth_rx_compl_v1, valid) / 32] = 0; in be_rx_compl_get()
2571 queue_tail_inc(&rxo->cq); in be_rx_compl_get()
2590 struct be_adapter *adapter = rxo->adapter; in be_post_rx_frags()
2592 struct be_queue_info *rxq = &rxo->q; in be_post_rx_frags()
2594 struct device *dev = &adapter->pdev->dev; in be_post_rx_frags()
2599 page_info = &rxo->page_info_tbl[rxq->head]; in be_post_rx_frags()
2600 for (posted = 0; posted < frags_needed && !page_info->page; posted++) { in be_post_rx_frags()
2602 pagep = be_alloc_pages(adapter->big_page_size, gfp); in be_post_rx_frags()
2604 rx_stats(rxo)->rx_post_fail++; in be_post_rx_frags()
2608 adapter->big_page_size, in be_post_rx_frags()
2613 adapter->drv_stats.dma_map_errors++; in be_post_rx_frags()
2621 page_info->page_offset = page_offset; in be_post_rx_frags()
2622 page_info->page = pagep; in be_post_rx_frags()
2625 frag_dmaaddr = page_dmaaddr + page_info->page_offset; in be_post_rx_frags()
2626 rxd->fragpa_lo = cpu_to_le32(frag_dmaaddr & 0xFFFFFFFF); in be_post_rx_frags()
2627 rxd->fragpa_hi = cpu_to_le32(upper_32_bits(frag_dmaaddr)); in be_post_rx_frags()
2631 adapter->big_page_size) { in be_post_rx_frags()
2633 page_info->last_frag = true; in be_post_rx_frags()
2641 page_info = &rxo->page_info_tbl[rxq->head]; in be_post_rx_frags()
2648 prev_page_info->last_frag = true; in be_post_rx_frags()
2653 atomic_add(posted, &rxq->used); in be_post_rx_frags()
2654 if (rxo->rx_post_starved) in be_post_rx_frags()
2655 rxo->rx_post_starved = false; in be_post_rx_frags()
2658 be_rxq_notify(adapter, rxq->id, notify); in be_post_rx_frags()
2659 posted -= notify; in be_post_rx_frags()
2661 } else if (atomic_read(&rxq->used) == 0) { in be_post_rx_frags()
2663 rxo->rx_post_starved = true; in be_post_rx_frags()
2671 tx_stats(txo)->tx_hdr_parse_err++; in be_update_tx_err()
2674 tx_stats(txo)->tx_dma_err++; in be_update_tx_err()
2677 tx_stats(txo)->tx_spoof_check_err++; in be_update_tx_err()
2686 tx_stats(txo)->tx_tso_err++; in lancer_update_tx_err()
2690 tx_stats(txo)->tx_spoof_check_err++; in lancer_update_tx_err()
2693 tx_stats(txo)->tx_qinq_err++; in lancer_update_tx_err()
2696 tx_stats(txo)->tx_internal_parity_err++; in lancer_update_tx_err()
2699 tx_stats(txo)->tx_dma_err++; in lancer_update_tx_err()
2702 tx_stats(txo)->tx_sge_err++; in lancer_update_tx_err()
2710 struct be_queue_info *tx_cq = &txo->cq; in be_tx_compl_get()
2711 struct be_tx_compl_info *txcp = &txo->txcp; in be_tx_compl_get()
2714 if (compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0) in be_tx_compl_get()
2721 txcp->status = GET_TX_COMPL_BITS(status, compl); in be_tx_compl_get()
2722 txcp->end_index = GET_TX_COMPL_BITS(wrb_index, compl); in be_tx_compl_get()
2724 if (txcp->status) { in be_tx_compl_get()
2726 lancer_update_tx_err(txo, txcp->status); in be_tx_compl_get()
2730 if (txcp->status == LANCER_TX_COMP_LSO_ERR || in be_tx_compl_get()
2731 txcp->status == LANCER_TX_COMP_PARITY_ERR || in be_tx_compl_get()
2732 txcp->status == LANCER_TX_COMP_SGE_ERR) in be_tx_compl_get()
2735 be_update_tx_err(txo, txcp->status); in be_tx_compl_get()
2742 compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0; in be_tx_compl_get()
2750 struct sk_buff **sent_skbs = txo->sent_skb_list; in be_tx_compl_process()
2751 struct be_queue_info *txq = &txo->q; in be_tx_compl_process()
2759 if (sent_skbs[txq->tail]) { in be_tx_compl_process()
2763 skb = sent_skbs[txq->tail]; in be_tx_compl_process()
2764 sent_skbs[txq->tail] = NULL; in be_tx_compl_process()
2770 frag_index = txq->tail; in be_tx_compl_process()
2771 unmap_tx_frag(&adapter->pdev->dev, wrb, in be_tx_compl_process()
2789 eqe = queue_tail_node(&eqo->q); in events_get()
2790 if (eqe->evt == 0) in events_get()
2794 eqe->evt = 0; in events_get()
2796 queue_tail_inc(&eqo->q); in events_get()
2802 /* Leaves the EQ is disarmed state */
2807 be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0); in be_eq_clean()
2810 /* Free posted rx buffers that were not used */
2813 struct be_queue_info *rxq = &rxo->q; in be_rxq_clean()
2816 while (atomic_read(&rxq->used) > 0) { in be_rxq_clean()
2818 put_page(page_info->page); in be_rxq_clean()
2821 BUG_ON(atomic_read(&rxq->used)); in be_rxq_clean()
2822 rxq->tail = 0; in be_rxq_clean()
2823 rxq->head = 0; in be_rxq_clean()
2828 struct be_queue_info *rx_cq = &rxo->cq; in be_rx_cq_clean()
2830 struct be_adapter *adapter = rxo->adapter; in be_rx_cq_clean()
2833 /* Consume pending rx completions. in be_rx_cq_clean()
2848 dev_warn(&adapter->pdev->dev, in be_rx_cq_clean()
2852 be_cq_notify(adapter, rx_cq->id, true, 0); in be_rx_cq_clean()
2856 be_cq_notify(adapter, rx_cq->id, false, 1); in be_rx_cq_clean()
2857 if (rxcp->num_rcvd == 0) in be_rx_cq_clean()
2863 be_cq_notify(adapter, rx_cq->id, false, 0); in be_rx_cq_clean()
2868 struct device *dev = &adapter->pdev->dev; in be_tx_compl_clean()
2878 pending_txqs = adapter->num_tx_qs; in be_tx_compl_clean()
2883 txq = &txo->q; in be_tx_compl_clean()
2887 txcp->end_index); in be_tx_compl_clean()
2891 be_cq_notify(adapter, txo->cq.id, false, cmpl); in be_tx_compl_clean()
2892 atomic_sub(num_wrbs, &txq->used); in be_tx_compl_clean()
2896 pending_txqs--; in be_tx_compl_clean()
2908 txq = &txo->q; in be_tx_compl_clean()
2910 if (atomic_read(&txq->used)) { in be_tx_compl_clean()
2911 dev_info(dev, "txq%d: cleaning %d pending tx-wrbs\n", in be_tx_compl_clean()
2912 i, atomic_read(&txq->used)); in be_tx_compl_clean()
2913 notified_idx = txq->tail; in be_tx_compl_clean()
2914 end_idx = txq->tail; in be_tx_compl_clean()
2915 index_adv(&end_idx, atomic_read(&txq->used) - 1, in be_tx_compl_clean()
2916 txq->len); in be_tx_compl_clean()
2917 /* Use the tx-compl process logic to handle requests in be_tx_compl_clean()
2921 atomic_sub(num_wrbs, &txq->used); in be_tx_compl_clean()
2922 BUG_ON(atomic_read(&txq->used)); in be_tx_compl_clean()
2923 txo->pend_wrb_cnt = 0; in be_tx_compl_clean()
2927 txq->head = notified_idx; in be_tx_compl_clean()
2928 txq->tail = notified_idx; in be_tx_compl_clean()
2939 if (eqo->q.created) { in be_evt_queues_destroy()
2941 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); in be_evt_queues_destroy()
2942 netif_napi_del(&eqo->napi); in be_evt_queues_destroy()
2943 free_cpumask_var(eqo->affinity_mask); in be_evt_queues_destroy()
2945 be_queue_free(adapter, &eqo->q); in be_evt_queues_destroy()
2951 struct be_queue_info *eq; in be_evt_queues_create() local
2956 /* need enough EQs to service both RX and TX queues */ in be_evt_queues_create()
2957 adapter->num_evt_qs = min_t(u16, num_irqs(adapter), in be_evt_queues_create()
2958 max(adapter->cfg_num_rx_irqs, in be_evt_queues_create()
2959 adapter->cfg_num_tx_irqs)); in be_evt_queues_create()
2961 adapter->aic_enabled = true; in be_evt_queues_create()
2964 int numa_node = dev_to_node(&adapter->pdev->dev); in be_evt_queues_create()
2966 aic = &adapter->aic_obj[i]; in be_evt_queues_create()
2967 eqo->adapter = adapter; in be_evt_queues_create()
2968 eqo->idx = i; in be_evt_queues_create()
2969 aic->max_eqd = BE_MAX_EQD; in be_evt_queues_create()
2971 eq = &eqo->q; in be_evt_queues_create()
2972 rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN, in be_evt_queues_create()
2981 if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) in be_evt_queues_create()
2982 return -ENOMEM; in be_evt_queues_create()
2984 eqo->affinity_mask); in be_evt_queues_create()
2985 netif_napi_add(adapter->netdev, &eqo->napi, be_poll, in be_evt_queues_create()
2995 q = &adapter->mcc_obj.q; in be_mcc_queues_destroy()
2996 if (q->created) in be_mcc_queues_destroy()
3000 q = &adapter->mcc_obj.cq; in be_mcc_queues_destroy()
3001 if (q->created) in be_mcc_queues_destroy()
3006 /* Must be called only after TX qs are created as MCC shares TX EQ */
3011 cq = &adapter->mcc_obj.cq; in be_mcc_queues_create()
3016 /* Use the default EQ for MCC completions */ in be_mcc_queues_create()
3017 if (be_cmd_cq_create(adapter, cq, &mcc_eqo(adapter)->q, true, 0)) in be_mcc_queues_create()
3020 q = &adapter->mcc_obj.q; in be_mcc_queues_create()
3036 return -1; in be_mcc_queues_create()
3046 q = &txo->q; in be_tx_queues_destroy()
3047 if (q->created) in be_tx_queues_destroy()
3051 q = &txo->cq; in be_tx_queues_destroy()
3052 if (q->created) in be_tx_queues_destroy()
3065 adapter->num_tx_qs = min(adapter->num_evt_qs, adapter->cfg_num_tx_irqs); in be_tx_qs_create()
3068 cq = &txo->cq; in be_tx_qs_create()
3074 u64_stats_init(&txo->stats.sync); in be_tx_qs_create()
3075 u64_stats_init(&txo->stats.sync_compl); in be_tx_qs_create()
3078 * one txq share an eq in be_tx_qs_create()
3080 eqo = &adapter->eq_obj[i % adapter->num_evt_qs]; in be_tx_qs_create()
3081 status = be_cmd_cq_create(adapter, cq, &eqo->q, false, 3); in be_tx_qs_create()
3085 status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN, in be_tx_qs_create()
3094 netif_set_xps_queue(adapter->netdev, eqo->affinity_mask, in be_tx_qs_create()
3095 eqo->idx); in be_tx_qs_create()
3098 dev_info(&adapter->pdev->dev, "created %d TX queue(s)\n", in be_tx_qs_create()
3099 adapter->num_tx_qs); in be_tx_qs_create()
3110 q = &rxo->cq; in be_rx_cqs_destroy()
3111 if (q->created) in be_rx_cqs_destroy()
3119 struct be_queue_info *eq, *cq; in be_rx_cqs_create() local
3123 adapter->num_rss_qs = in be_rx_cqs_create()
3124 min(adapter->num_evt_qs, adapter->cfg_num_rx_irqs); in be_rx_cqs_create()
3127 if (adapter->num_rss_qs < 2) in be_rx_cqs_create()
3128 adapter->num_rss_qs = 0; in be_rx_cqs_create()
3130 adapter->num_rx_qs = adapter->num_rss_qs + adapter->need_def_rxq; in be_rx_cqs_create()
3135 if (adapter->num_rx_qs == 0) in be_rx_cqs_create()
3136 adapter->num_rx_qs = 1; in be_rx_cqs_create()
3138 adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; in be_rx_cqs_create()
3140 rxo->adapter = adapter; in be_rx_cqs_create()
3141 cq = &rxo->cq; in be_rx_cqs_create()
3147 u64_stats_init(&rxo->stats.sync); in be_rx_cqs_create()
3148 eq = &adapter->eq_obj[i % adapter->num_evt_qs].q; in be_rx_cqs_create()
3149 rc = be_cmd_cq_create(adapter, cq, eq, false, 3); in be_rx_cqs_create()
3154 dev_info(&adapter->pdev->dev, in be_rx_cqs_create()
3155 "created %d RX queue(s)\n", adapter->num_rx_qs); in be_rx_cqs_create()
3162 struct be_adapter *adapter = eqo->adapter; in be_intx()
3165 /* IRQ is not expected when NAPI is scheduled as the EQ in be_intx()
3168 * a while to de-assert INTx or in BE2 where occasionaly in be_intx()
3169 * an interrupt may be raised even when EQ is unarmed. in be_intx()
3173 if (napi_schedule_prep(&eqo->napi)) { in be_intx()
3175 __napi_schedule(&eqo->napi); in be_intx()
3177 eqo->spurious_intr = 0; in be_intx()
3179 be_eq_notify(adapter, eqo->q.id, false, true, num_evts, 0); in be_intx()
3185 if (num_evts || eqo->spurious_intr++ == 0) in be_intx()
3195 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_msix()
3196 napi_schedule(&eqo->napi); in be_msix()
3202 return (rxcp->tcpf && !rxcp->err && rxcp->l4_csum) ? true : false; in do_gro()
3208 struct be_adapter *adapter = rxo->adapter; in be_process_rx()
3209 struct be_queue_info *rx_cq = &rxo->cq; in be_process_rx()
3220 if (unlikely(rxcp->num_rcvd == 0)) in be_process_rx()
3224 if (unlikely(!rxcp->pkt_size)) { in be_process_rx()
3232 if (unlikely(rxcp->port != adapter->port_num && in be_process_rx()
3244 frags_consumed += rxcp->num_rcvd; in be_process_rx()
3249 be_cq_notify(adapter, rx_cq->id, true, work_done); in be_process_rx()
3251 /* When an rx-obj gets into post_starved state, just in be_process_rx()
3254 if (atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM && in be_process_rx()
3255 !rxo->rx_post_starved) in be_process_rx()
3272 num_wrbs += be_tx_compl_process(adapter, txo, txcp->end_index); in be_process_tx()
3277 be_cq_notify(adapter, txo->cq.id, true, work_done); in be_process_tx()
3278 atomic_sub(num_wrbs, &txo->q.used); in be_process_tx()
3282 if (__netif_subqueue_stopped(adapter->netdev, idx) && in be_process_tx()
3284 netif_wake_subqueue(adapter->netdev, idx); in be_process_tx()
3287 u64_stats_update_begin(&tx_stats(txo)->sync_compl); in be_process_tx()
3288 tx_stats(txo)->tx_compl += work_done; in be_process_tx()
3289 u64_stats_update_end(&tx_stats(txo)->sync_compl); in be_process_tx()
3296 struct be_adapter *adapter = eqo->adapter; in be_poll()
3328 be_eq_notify(adapter, eqo->q.id, true, false, num_evts, in be_poll()
3332 be_eq_notify(adapter, eqo->q.id, false, false, num_evts, 0); in be_poll()
3341 struct device *dev = &adapter->pdev->dev; in be_detect_error()
3349 sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); in be_detect_error()
3352 sliport_err1 = ioread32(adapter->db + in be_detect_error()
3354 sliport_err2 = ioread32(adapter->db + in be_detect_error()
3371 ue_lo = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_LOW); in be_detect_error()
3372 ue_hi = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_HIGH); in be_detect_error()
3373 ue_lo_mask = ioread32(adapter->pcicfg + in be_detect_error()
3375 ue_hi_mask = ioread32(adapter->pcicfg + in be_detect_error()
3420 pci_disable_msix(adapter->pdev); in be_msix_disable()
3421 adapter->num_msix_vec = 0; in be_msix_disable()
3422 adapter->num_msix_roce_vec = 0; in be_msix_disable()
3429 struct device *dev = &adapter->pdev->dev; in be_msix_enable()
3438 be_max_func_eqs(adapter) - be_max_nic_eqs(adapter); in be_msix_enable()
3442 num_vec = max(adapter->cfg_num_rx_irqs, in be_msix_enable()
3443 adapter->cfg_num_tx_irqs); in be_msix_enable()
3447 adapter->msix_entries[i].entry = i; in be_msix_enable()
3449 num_vec = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, in be_msix_enable()
3455 adapter->num_msix_roce_vec = num_vec / 2; in be_msix_enable()
3456 dev_info(dev, "enabled %d MSI-x vector(s) for RoCE\n", in be_msix_enable()
3457 adapter->num_msix_roce_vec); in be_msix_enable()
3460 adapter->num_msix_vec = num_vec - adapter->num_msix_roce_vec; in be_msix_enable()
3462 dev_info(dev, "enabled %d MSI-x vector(s) for NIC\n", in be_msix_enable()
3463 adapter->num_msix_vec); in be_msix_enable()
3478 return adapter->msix_entries[eqo->msix_idx].vector; in be_msix_vec_get()
3483 struct net_device *netdev = adapter->netdev; in be_msix_register()
3488 sprintf(eqo->desc, "%s-q%d", netdev->name, i); in be_msix_register()
3490 status = request_irq(vec, be_msix, 0, eqo->desc, eqo); in be_msix_register()
3494 irq_set_affinity_hint(vec, eqo->affinity_mask); in be_msix_register()
3499 for (i--; i >= 0; i--) { in be_msix_register()
3500 eqo = &adapter->eq_obj[i]; in be_msix_register()
3503 dev_warn(&adapter->pdev->dev, "MSIX Request IRQ failed - err %d\n", in be_msix_register()
3511 struct net_device *netdev = adapter->netdev; in be_irq_register()
3523 /* INTx: only the first EQ is used */ in be_irq_register()
3524 netdev->irq = adapter->pdev->irq; in be_irq_register()
3525 status = request_irq(netdev->irq, be_intx, IRQF_SHARED, netdev->name, in be_irq_register()
3526 &adapter->eq_obj[0]); in be_irq_register()
3528 dev_err(&adapter->pdev->dev, in be_irq_register()
3529 "INTx request IRQ failed - err %d\n", status); in be_irq_register()
3533 adapter->isr_registered = true; in be_irq_register()
3539 struct net_device *netdev = adapter->netdev; in be_irq_unregister()
3543 if (!adapter->isr_registered) in be_irq_unregister()
3548 free_irq(netdev->irq, &adapter->eq_obj[0]); in be_irq_unregister()
3560 adapter->isr_registered = false; in be_irq_unregister()
3565 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_destroy()
3571 q = &rxo->q; in be_rx_qs_destroy()
3572 if (q->created) { in be_rx_qs_destroy()
3581 if (atomic_read(&q->used) == 0) in be_rx_qs_destroy()
3593 if (rss->rss_flags) { in be_rx_qs_destroy()
3594 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_destroy()
3595 be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_destroy()
3596 128, rss->rss_hkey); in be_rx_qs_destroy()
3605 be_dev_mac_del(adapter, adapter->pmac_id[0]); in be_disable_if_filters()
3606 eth_zero_addr(adapter->dev_mac); in be_disable_if_filters()
3615 * - VF's IFACE flags get cleared in the detach path in be_disable_if_filters()
3616 * - IFACE create is issued by the VF in the attach path in be_disable_if_filters()
3617 * Due to a bug in the BE3/Skyhawk-R FW in be_disable_if_filters()
3624 * To avoid this, disable RX-filter flags only for Lancer. in be_disable_if_filters()
3628 adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS; in be_disable_if_filters()
3641 if (!(adapter->flags & BE_FLAGS_SETUP_DONE)) in be_close()
3651 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { in be_close()
3653 napi_disable(&eqo->napi); in be_close()
3655 adapter->flags &= ~BE_FLAGS_NAPI_ENABLED; in be_close()
3672 synchronize_irq(netdev->irq); in be_close()
3683 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_create()
3689 rc = be_queue_alloc(adapter, &rxo->q, RX_Q_LEN, in be_rx_qs_create()
3695 if (adapter->need_def_rxq || !adapter->num_rss_qs) { in be_rx_qs_create()
3697 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3698 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3699 false, &rxo->rss_id); in be_rx_qs_create()
3705 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3706 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3707 true, &rxo->rss_id); in be_rx_qs_create()
3713 for (j = 0; j < RSS_INDIR_TABLE_LEN; j += adapter->num_rss_qs) { in be_rx_qs_create()
3717 rss->rsstable[j + i] = rxo->rss_id; in be_rx_qs_create()
3718 rss->rss_queue[j + i] = i; in be_rx_qs_create()
3721 rss->rss_flags = RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4 | in be_rx_qs_create()
3725 rss->rss_flags |= RSS_ENABLE_UDP_IPV4 | in be_rx_qs_create()
3729 rc = be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_create()
3732 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_create()
3736 memcpy(rss->rss_hkey, rss_key, RSS_HASH_KEY_LEN); in be_rx_qs_create()
3738 /* Disable RSS, if only default RX Q is created */ in be_rx_qs_create()
3739 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_create()
3743 /* Post 1 less than RXQ-len to avoid head being equal to tail, in be_rx_qs_create()
3747 be_post_rx_frags(rxo, GFP_KERNEL, RX_Q_LEN - 1); in be_rx_qs_create()
3760 /* Normally this condition usually true as the ->dev_mac is zeroed. in be_enable_if_filters()
3761 * But on BE3 VFs the initial MAC is pre-programmed by PF and in be_enable_if_filters()
3764 if (!ether_addr_equal(adapter->dev_mac, adapter->netdev->dev_addr)) { in be_enable_if_filters()
3765 int old_pmac_id = -1; in be_enable_if_filters()
3767 /* Remember old programmed MAC if any - can happen on BE3 VF */ in be_enable_if_filters()
3768 if (!is_zero_ether_addr(adapter->dev_mac)) in be_enable_if_filters()
3769 old_pmac_id = adapter->pmac_id[0]; in be_enable_if_filters()
3771 status = be_dev_mac_add(adapter, adapter->netdev->dev_addr); in be_enable_if_filters()
3778 if (old_pmac_id >= 0 && old_pmac_id != adapter->pmac_id[0]) in be_enable_if_filters()
3781 ether_addr_copy(adapter->dev_mac, adapter->netdev->dev_addr); in be_enable_if_filters()
3784 if (adapter->vlans_added) in be_enable_if_filters()
3814 be_cq_notify(adapter, rxo->cq.id, true, 0); in be_open()
3817 be_cq_notify(adapter, txo->cq.id, true, 0); in be_open()
3822 napi_enable(&eqo->napi); in be_open()
3823 be_eq_notify(adapter, eqo->q.id, true, true, 0, 0); in be_open()
3825 adapter->flags |= BE_FLAGS_NAPI_ENABLED; in be_open()
3837 be_close(adapter->netdev); in be_open()
3838 return -EIO; in be_open()
3845 addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0); in be_vf_eth_addr_generate()
3851 memcpy(mac, adapter->netdev->dev_addr, 3); in be_vf_eth_addr_generate()
3872 vf_cfg->if_handle, in be_vf_eth_addr_config()
3873 &vf_cfg->pmac_id, vf + 1); in be_vf_eth_addr_config()
3875 status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle, in be_vf_eth_addr_config()
3879 dev_err(&adapter->pdev->dev, in be_vf_eth_addr_config()
3883 memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); in be_vf_eth_addr_config()
3897 status = be_cmd_get_active_mac(adapter, vf_cfg->pmac_id, in be_vfs_mac_query()
3898 mac, vf_cfg->if_handle, in be_vfs_mac_query()
3902 memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); in be_vfs_mac_query()
3912 if (pci_vfs_assigned(adapter->pdev)) { in be_vf_clear()
3913 dev_warn(&adapter->pdev->dev, in be_vf_clear()
3918 pci_disable_sriov(adapter->pdev); in be_vf_clear()
3922 be_cmd_pmac_del(adapter, vf_cfg->if_handle, in be_vf_clear()
3923 vf_cfg->pmac_id, vf + 1); in be_vf_clear()
3925 be_cmd_set_mac(adapter, NULL, vf_cfg->if_handle, in be_vf_clear()
3928 be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1); in be_vf_clear()
3933 adapter->if_handle, in be_vf_clear()
3936 kfree(adapter->vf_cfg); in be_vf_clear()
3937 adapter->num_vfs = 0; in be_vf_clear()
3938 adapter->flags &= ~BE_FLAGS_SRIOV_ENABLED; in be_vf_clear()
3951 if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) { in be_cancel_worker()
3952 cancel_delayed_work_sync(&adapter->work); in be_cancel_worker()
3953 adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED; in be_cancel_worker()
3959 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_cancel_err_detection()
3964 if (adapter->flags & BE_FLAGS_ERR_DETECTION_SCHEDULED) { in be_cancel_err_detection()
3965 cancel_delayed_work_sync(&err_rec->err_detection_work); in be_cancel_err_detection()
3966 adapter->flags &= ~BE_FLAGS_ERR_DETECTION_SCHEDULED; in be_cancel_err_detection()
3984 struct device *dev = &adapter->pdev->dev; in be_vxlan_set_port()
3987 status = be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_set_port()
3993 adapter->flags |= BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_set_port()
3995 status = be_cmd_set_vxlan_port(adapter, ti->port); in be_vxlan_set_port()
4000 adapter->vxlan_port = ti->port; in be_vxlan_set_port()
4002 netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | in be_vxlan_set_port()
4007 be16_to_cpu(ti->port)); in be_vxlan_set_port()
4016 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) in be_vxlan_unset_port()
4017 be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_unset_port()
4020 if (adapter->vxlan_port) in be_vxlan_unset_port()
4023 adapter->flags &= ~BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_unset_port()
4024 adapter->vxlan_port = 0; in be_vxlan_unset_port()
4026 netdev->hw_enc_features = 0; in be_vxlan_unset_port()
4043 struct be_resources res = adapter->pool_res; in be_calculate_vf_res()
4050 /* Divide the rx queues evenly among the VFs and the PF, capped in be_calculate_vf_res()
4051 * at VF-EQ-count. Any remainder queues belong to the PF. in be_calculate_vf_res()
4056 /* Skyhawk-R chip supports only MAX_PORT_RSS_TABLES in be_calculate_vf_res()
4076 vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT); in be_calculate_vf_res()
4090 vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT); in be_calculate_vf_res()
4094 vft_res->vf_if_cap_flags = vf_if_cap_flags; in be_calculate_vf_res()
4095 vft_res->max_rx_qs = num_vf_qs; in be_calculate_vf_res()
4096 vft_res->max_rss_qs = num_vf_qs; in be_calculate_vf_res()
4097 vft_res->max_tx_qs = res.max_tx_qs / (num_vfs + 1); in be_calculate_vf_res()
4098 vft_res->max_cq_count = res.max_cq_count / (num_vfs + 1); in be_calculate_vf_res()
4104 vft_res->max_uc_mac = res.max_uc_mac / (num_vfs + 1); in be_calculate_vf_res()
4107 vft_res->max_vlans = res.max_vlans / (num_vfs + 1); in be_calculate_vf_res()
4110 vft_res->max_iface_count = res.max_iface_count / (num_vfs + 1); in be_calculate_vf_res()
4113 vft_res->max_mcc_count = res.max_mcc_count / (num_vfs + 1); in be_calculate_vf_res()
4118 be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_if_destroy()
4120 kfree(adapter->pmac_id); in be_if_destroy()
4121 adapter->pmac_id = NULL; in be_if_destroy()
4123 kfree(adapter->mc_list); in be_if_destroy()
4124 adapter->mc_list = NULL; in be_if_destroy()
4126 kfree(adapter->uc_list); in be_if_destroy()
4127 adapter->uc_list = NULL; in be_if_destroy()
4132 struct pci_dev *pdev = adapter->pdev; in be_clear()
4142 /* Re-configure FW to distribute resources evenly across max-supported in be_clear()
4150 be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_clear()
4155 be_vxlan_unset_port(adapter->netdev, 0, 0, NULL); in be_clear()
4162 adapter->flags &= ~BE_FLAGS_SETUP_DONE; in be_clear()
4194 &vf_cfg->if_handle, vf + 1); in be_vfs_if_create()
4207 adapter->vf_cfg = kcalloc(adapter->num_vfs, sizeof(*vf_cfg), in be_vf_setup_init()
4209 if (!adapter->vf_cfg) in be_vf_setup_init()
4210 return -ENOMEM; in be_vf_setup_init()
4213 vf_cfg->if_handle = -1; in be_vf_setup_init()
4214 vf_cfg->pmac_id = -1; in be_vf_setup_init()
4221 struct device *dev = &adapter->pdev->dev; in be_vf_setup()
4226 old_vfs = pci_num_vf(adapter->pdev); in be_vf_setup()
4254 status = be_cmd_get_fn_privileges(adapter, &vf_cfg->privileges, in be_vf_setup()
4256 if (!status && !(vf_cfg->privileges & BE_PRIV_FILTMGMT)) { in be_vf_setup()
4258 vf_cfg->privileges | in be_vf_setup()
4262 vf_cfg->privileges |= BE_PRIV_FILTMGMT; in be_vf_setup()
4273 vf_cfg->if_handle, NULL, in be_vf_setup()
4276 vf_cfg->spoofchk = spoofchk; in be_vf_setup()
4287 status = pci_enable_sriov(adapter->pdev, adapter->num_vfs); in be_vf_setup()
4290 adapter->num_vfs = 0; in be_vf_setup()
4298 adapter->if_handle, in be_vf_setup()
4304 adapter->flags |= BE_FLAGS_SRIOV_ENABLED; in be_vf_setup()
4332 bool use_sriov = adapter->num_vfs ? 1 : 0; in BEx_get_resources()
4335 res->max_uc_mac = BE_UC_PMAC_COUNT; in BEx_get_resources()
4337 res->max_uc_mac = BE_VF_UC_PMAC_COUNT; in BEx_get_resources()
4339 adapter->mc_type = be_convert_mc_type(adapter->function_mode); in BEx_get_resources()
4343 * when multi-channel is enabled in BEx_get_resources()
4346 res->max_vlans = BE_NUM_VLANS_SUPPORTED/8; in BEx_get_resources()
4348 /* In a non-qnq multichannel mode, the pvid in BEx_get_resources()
4351 res->max_vlans = (BE_NUM_VLANS_SUPPORTED / 4) - 1; in BEx_get_resources()
4353 res->max_vlans = BE_NUM_VLANS_SUPPORTED; in BEx_get_resources()
4356 res->max_mcast_mac = BE_MAX_MC; in BEx_get_resources()
4359 * 2) Create multiple TX rings on a BE3-R multi-channel interface in BEx_get_resources()
4360 * *only* if it is RSS-capable. in BEx_get_resources()
4362 if (BE2_chip(adapter) || use_sriov || (adapter->port_num > 1) || in BEx_get_resources()
4365 !(adapter->function_caps & BE_FUNCTION_CAPS_RSS))) { in BEx_get_resources()
4366 res->max_tx_qs = 1; in BEx_get_resources()
4367 } else if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) { in BEx_get_resources()
4371 * GET_PROFILE_CONFIG cmd to query the per-function TXQ limits in BEx_get_resources()
4377 res->max_tx_qs = super_nic_res.max_tx_qs ? : BE3_MAX_TX_QS; in BEx_get_resources()
4379 res->max_tx_qs = BE3_MAX_TX_QS; in BEx_get_resources()
4382 if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && in BEx_get_resources()
4384 res->max_rss_qs = (adapter->be3_native) ? in BEx_get_resources()
4386 res->max_rx_qs = res->max_rss_qs + 1; in BEx_get_resources()
4389 res->max_evt_qs = (be_max_vfs(adapter) > 0) ? in BEx_get_resources()
4392 res->max_evt_qs = 1; in BEx_get_resources()
4394 res->if_cap_flags = BE_IF_CAP_FLAGS_WANT; in BEx_get_resources()
4395 res->if_cap_flags &= ~BE_IF_FLAGS_DEFQ_RSS; in BEx_get_resources()
4396 if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS)) in BEx_get_resources()
4397 res->if_cap_flags &= ~BE_IF_FLAGS_RSS; in BEx_get_resources()
4402 adapter->vlan_prio_bmap = 0xff; in be_setup_init()
4403 adapter->phy.link_speed = -1; in be_setup_init()
4404 adapter->if_handle = -1; in be_setup_init()
4405 adapter->be3_native = false; in be_setup_init()
4406 adapter->if_flags = 0; in be_setup_init()
4407 adapter->phy_state = BE_UNKNOWN_PHY_STATE; in be_setup_init()
4409 adapter->cmd_privileges = MAX_PRIVILEGES; in be_setup_init()
4411 adapter->cmd_privileges = MIN_PRIVILEGES; in be_setup_init()
4416 * As a result, in the case of SRIOV and in particular multi-partition configs
4417 * the driver needs to calcuate a proportional share of RSS Tables per PF-pool
4418 * for distribution between the VFs. This self-imposed limit will determine the
4430 rss_tables_on_port = MAX_PORT_RSS_TABLES - port_res.nic_pfs; in be_calculate_pf_pool_rss_tables()
4435 adapter->pool_res.max_rss_tables = in be_calculate_pf_pool_rss_tables()
4449 max_vfs = pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4453 adapter->pool_res = res; in be_get_sriov_config()
4457 * Instead use the TotalVFs value stored in the pci-dev struct. in be_get_sriov_config()
4459 old_vfs = pci_num_vf(adapter->pdev); in be_get_sriov_config()
4461 dev_info(&adapter->pdev->dev, "%d VFs are already enabled\n", in be_get_sriov_config()
4464 adapter->pool_res.max_vfs = in be_get_sriov_config()
4465 pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4466 adapter->num_vfs = old_vfs; in be_get_sriov_config()
4471 dev_info(&adapter->pdev->dev, in be_get_sriov_config()
4480 int old_vfs = pci_num_vf(adapter->pdev); in be_alloc_sriov_res()
4487 pci_sriov_set_totalvfs(adapter->pdev, be_max_vfs(adapter)); in be_alloc_sriov_res()
4489 /* When the HW is in SRIOV capable configuration, the PF-pool in be_alloc_sriov_res()
4496 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, 0, in be_alloc_sriov_res()
4499 dev_err(&adapter->pdev->dev, in be_alloc_sriov_res()
4506 struct device *dev = &adapter->pdev->dev; in be_get_resources()
4510 /* For Lancer, SH etc read per-function resource limits from FW. in be_get_resources()
4512 * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits in be_get_resources()
4524 res.max_rss_qs -= 1; in be_get_resources()
4530 adapter->res = res; in be_get_resources()
4532 /* If FW supports RSS default queue, then skip creating non-RSS in be_get_resources()
4533 * queue for non-IP traffic. in be_get_resources()
4535 adapter->need_def_rxq = (be_if_cap_flags(adapter) & in be_get_resources()
4542 dev_info(dev, "Max: uc-macs %d, mc-macs %d, vlans %d\n", in be_get_resources()
4546 /* Ensure RX and TX queues are created in pairs at init time */ in be_get_resources()
4547 adapter->cfg_num_rx_irqs = in be_get_resources()
4550 adapter->cfg_num_tx_irqs = adapter->cfg_num_rx_irqs; in be_get_resources()
4568 be_cmd_get_fat_dump_len(adapter, &adapter->fat_dump_len); in be_get_config()
4572 adapter->msg_enable = in be_get_config()
4577 pci_enable_wake(adapter->pdev, PCI_D3hot, adapter->wol_en); in be_get_config()
4578 pci_enable_wake(adapter->pdev, PCI_D3cold, adapter->wol_en); in be_get_config()
4585 dev_info(&adapter->pdev->dev, in be_get_config()
4597 if (is_zero_ether_addr(adapter->netdev->dev_addr)) { in be_mac_setup()
4602 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); in be_mac_setup()
4603 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); in be_mac_setup()
4607 memcpy(adapter->dev_mac, mac, ETH_ALEN); in be_mac_setup()
4615 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_schedule_worker()
4616 adapter->flags |= BE_FLAGS_WORKER_SCHEDULED; in be_schedule_worker()
4631 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_schedule_err_detection()
4636 queue_delayed_work(be_err_recovery_workq, &err_rec->err_detection_work, in be_schedule_err_detection()
4638 adapter->flags |= BE_FLAGS_ERR_DETECTION_SCHEDULED; in be_schedule_err_detection()
4643 struct net_device *netdev = adapter->netdev; in be_setup_queues()
4662 status = netif_set_real_num_rx_queues(netdev, adapter->num_rx_qs); in be_setup_queues()
4666 status = netif_set_real_num_tx_queues(netdev, adapter->num_tx_qs); in be_setup_queues()
4672 dev_err(&adapter->pdev->dev, "queue_setup failed\n"); in be_setup_queues()
4683 adapter->pmac_id = kcalloc(be_max_uc(adapter), in be_if_create()
4684 sizeof(*adapter->pmac_id), GFP_KERNEL); in be_if_create()
4685 if (!adapter->pmac_id) in be_if_create()
4686 return -ENOMEM; in be_if_create()
4688 adapter->mc_list = kcalloc(be_max_mc(adapter), in be_if_create()
4689 sizeof(*adapter->mc_list), GFP_KERNEL); in be_if_create()
4690 if (!adapter->mc_list) in be_if_create()
4691 return -ENOMEM; in be_if_create()
4693 adapter->uc_list = kcalloc(be_max_uc(adapter), in be_if_create()
4694 sizeof(*adapter->uc_list), GFP_KERNEL); in be_if_create()
4695 if (!adapter->uc_list) in be_if_create()
4696 return -ENOMEM; in be_if_create()
4698 if (adapter->cfg_num_rx_irqs == 1) in be_if_create()
4704 &adapter->if_handle, 0); in be_if_create()
4714 struct net_device *netdev = adapter->netdev; in be_update_queues()
4719 * function, synchronize with an already-running dev_watchdog in be_update_queues()
4731 /* If any vectors have been shared with RoCE we cannot re-program in be_update_queues()
4734 if (!adapter->num_msix_roce_vec) in be_update_queues()
4738 status = be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_update_queues()
4758 /* The IF was destroyed and re-created. We need to clear in be_update_queues()
4764 adapter->if_flags &= ~BE_IF_FLAGS_ALL_PROMISCUOUS; in be_update_queues()
4791 return pci_num_vf(adapter->pdev) == 0; in be_reset_required()
4828 struct device *dev = &adapter->pdev->dev; in be_setup()
4876 be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0); in be_setup()
4883 dev_info(dev, "FW version is %s\n", adapter->fw_ver); in be_setup()
4885 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) { in be_setup()
4887 adapter->fw_ver); in be_setup()
4891 status = be_cmd_set_flow_control(adapter, adapter->tx_fc, in be_setup()
4892 adapter->rx_fc); in be_setup()
4894 be_cmd_get_flow_control(adapter, &adapter->tx_fc, in be_setup()
4895 &adapter->rx_fc); in be_setup()
4897 dev_info(&adapter->pdev->dev, "HW Flow control - TX:%d RX:%d\n", in be_setup()
4898 adapter->tx_fc, adapter->rx_fc); in be_setup()
4910 be_cmd_set_hsw_config(adapter, 0, 0, adapter->if_handle, in be_setup()
4913 if (adapter->num_vfs) in be_setup()
4918 adapter->phy.fc_autoneg = 1; in be_setup()
4924 adapter->flags |= BE_FLAGS_SETUP_DONE; in be_setup()
4939 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_netpoll()
4940 napi_schedule(&eqo->napi); in be_netpoll()
4950 if (!netif_running(adapter->netdev)) { in be_load_fw()
4951 dev_err(&adapter->pdev->dev, in be_load_fw()
4953 return -ENETDOWN; in be_load_fw()
4956 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); in be_load_fw()
4960 dev_info(&adapter->pdev->dev, "Flashing firmware file %s\n", fw_file); in be_load_fw()
4985 return -EOPNOTSUPP; in be_ndo_bridge_setlink()
4989 return -EINVAL; in be_ndo_bridge_setlink()
4996 return -EINVAL; in be_ndo_bridge_setlink()
5000 return -EOPNOTSUPP; in be_ndo_bridge_setlink()
5003 return -EINVAL; in be_ndo_bridge_setlink()
5006 adapter->if_handle, in be_ndo_bridge_setlink()
5013 dev_info(&adapter->pdev->dev, "enabled switch mode: %s\n", in be_ndo_bridge_setlink()
5019 dev_err(&adapter->pdev->dev, "Failed to set switch mode %s\n", in be_ndo_bridge_setlink()
5035 /* VEB is disabled in non-SR-IOV profiles on BE3/Lancer */ in be_ndo_bridge_getlink()
5036 if (!pci_sriov_get_totalvfs(adapter->pdev)) in be_ndo_bridge_getlink()
5041 adapter->if_handle, &hsw_mode, in be_ndo_bridge_getlink()
5063 dev_err(&adapter->pdev->dev, in be_alloc_work()
5068 INIT_WORK(&work->work, func); in be_alloc_work()
5069 work->adapter = adapter; in be_alloc_work()
5092 (skb_shinfo(skb)->gso_size < 256 || in be_features_check()
5093 skb_shinfo(skb)->gso_segs == 1)) in be_features_check()
5098 * Q-in-Q packets. in be_features_check()
5102 if (!skb->encapsulation || in be_features_check()
5103 !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) in be_features_check()
5110 * offloads are configured in Skyhawk-R. in be_features_check()
5114 l4_hdr = ip_hdr(skb)->protocol; in be_features_check()
5117 l4_hdr = ipv6_hdr(skb)->nexthdr; in be_features_check()
5124 skb->inner_protocol_type != ENCAP_TYPE_ETHER || in be_features_check()
5125 skb->inner_protocol != htons(ETH_P_TEB) || in be_features_check()
5126 skb_inner_mac_header(skb) - skb_transport_header(skb) != in be_features_check()
5128 !adapter->vxlan_port || in be_features_check()
5129 udp_hdr(skb)->dest != adapter->vxlan_port) in be_features_check()
5143 return -ENOSPC; in be_get_phys_port_id()
5145 ppid->id[0] = adapter->hba_port_num + 1; in be_get_phys_port_id()
5146 id = &ppid->id[1]; in be_get_phys_port_id()
5147 for (i = CNTL_SERIAL_NUM_WORDS - 1; i >= 0; in be_get_phys_port_id()
5148 i--, id += CNTL_SERIAL_NUM_WORD_SZ) in be_get_phys_port_id()
5149 memcpy(id, &adapter->serial_num[i], CNTL_SERIAL_NUM_WORD_SZ); in be_get_phys_port_id()
5151 ppid->id_len = id_len; in be_get_phys_port_id()
5163 queue_work(be_wq, &work->work); in be_set_rx_mode()
5198 netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | in be_netdev_init()
5203 netdev->hw_features |= NETIF_F_RXHASH; in be_netdev_init()
5205 netdev->features |= netdev->hw_features | in be_netdev_init()
5208 netdev->vlan_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | in be_netdev_init()
5211 netdev->priv_flags |= IFF_UNICAST_FLT; in be_netdev_init()
5213 netdev->flags |= IFF_MULTICAST; in be_netdev_init()
5215 netif_set_gso_max_size(netdev, BE_MAX_GSO_SIZE - ETH_HLEN); in be_netdev_init()
5217 netdev->netdev_ops = &be_netdev_ops; in be_netdev_init()
5219 netdev->ethtool_ops = &be_ethtool_ops; in be_netdev_init()
5222 netdev->udp_tunnel_nic_info = &be_udp_tunnels; in be_netdev_init()
5224 /* MTU range: 256 - 9000 */ in be_netdev_init()
5225 netdev->min_mtu = BE_MIN_MTU; in be_netdev_init()
5226 netdev->max_mtu = BE_MAX_MTU; in be_netdev_init()
5231 struct net_device *netdev = adapter->netdev; in be_cleanup()
5244 struct net_device *netdev = adapter->netdev; in be_resume()
5268 dev_info(&adapter->pdev->dev, "Initiating chip soft reset\n"); in be_soft_reset()
5269 val = ioread32(adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5271 iowrite32(val, adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5276 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_err_is_recoverable()
5291 dev_err(&adapter->pdev->dev, "Recoverable HW error code: 0x%x\n", in be_err_is_recoverable()
5294 if (time_before_eq(jiffies - err_rec->probe_time, initial_idle_time)) { in be_err_is_recoverable()
5295 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5301 if (err_rec->last_recovery_time && time_before_eq( in be_err_is_recoverable()
5302 jiffies - err_rec->last_recovery_time, recovery_interval)) { in be_err_is_recoverable()
5303 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5309 if (ue_err_code == err_rec->last_err_code) { in be_err_is_recoverable()
5310 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5315 err_rec->last_recovery_time = jiffies; in be_err_is_recoverable()
5316 err_rec->last_err_code = ue_err_code; in be_err_is_recoverable()
5322 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_tpe_recover()
5323 int status = -EAGAIN; in be_tpe_recover()
5326 switch (err_rec->recovery_state) { in be_tpe_recover()
5328 err_rec->recovery_state = ERR_RECOVERY_ST_DETECT; in be_tpe_recover()
5329 err_rec->resched_delay = ERR_RECOVERY_UE_DETECT_DURATION; in be_tpe_recover()
5336 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5338 status = -EINVAL; in be_tpe_recover()
5339 err_rec->resched_delay = 0; in be_tpe_recover()
5343 dev_err(&adapter->pdev->dev, "Recoverable HW error detected\n"); in be_tpe_recover()
5350 if (adapter->pf_num == 0) { in be_tpe_recover()
5351 err_rec->recovery_state = ERR_RECOVERY_ST_RESET; in be_tpe_recover()
5352 err_rec->resched_delay = err_rec->ue_to_reset_time - in be_tpe_recover()
5357 err_rec->recovery_state = ERR_RECOVERY_ST_PRE_POLL; in be_tpe_recover()
5358 err_rec->resched_delay = err_rec->ue_to_poll_time - in be_tpe_recover()
5364 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5366 status = -EIO; in be_tpe_recover()
5367 err_rec->resched_delay = 0; in be_tpe_recover()
5371 err_rec->recovery_state = ERR_RECOVERY_ST_PRE_POLL; in be_tpe_recover()
5372 err_rec->resched_delay = err_rec->ue_to_poll_time - in be_tpe_recover()
5373 err_rec->ue_to_reset_time; in be_tpe_recover()
5377 err_rec->recovery_state = ERR_RECOVERY_ST_REINIT; in be_tpe_recover()
5378 err_rec->resched_delay = 0; in be_tpe_recover()
5383 status = -EINVAL; in be_tpe_recover()
5384 err_rec->resched_delay = 0; in be_tpe_recover()
5396 if (!adapter->error_recovery.recovery_supported || in be_err_recover()
5397 adapter->priv_flags & BE_DISABLE_TPE_RECOVERY) in be_err_recover()
5398 return -EIO; in be_err_recover()
5411 adapter->flags |= BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5419 adapter->flags &= ~BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5434 struct device *dev = &adapter->pdev->dev; in be_err_detection_task()
5443 err_rec->recovery_retries = 0; in be_err_detection_task()
5444 err_rec->recovery_state = ERR_RECOVERY_ST_NONE; in be_err_detection_task()
5447 } else if (!lancer_chip(adapter) && err_rec->resched_delay) { in be_err_detection_task()
5449 if (adapter->pf_num == 0 && in be_err_detection_task()
5450 err_rec->recovery_state > ERR_RECOVERY_ST_DETECT) in be_err_detection_task()
5451 dev_err(&adapter->pdev->dev, in be_err_detection_task()
5453 resched_delay = err_rec->resched_delay; in be_err_detection_task()
5459 dev_err(dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5461 } else if (lancer_chip(adapter) && err_rec->recovery_retries++ < in be_err_detection_task()
5467 dev_err(&adapter->pdev->dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5487 dev_err(&adapter->pdev->dev, in be_log_sfp_info()
5489 adapter->port_name, in be_log_sfp_info()
5490 be_misconfig_evt_port_state[adapter->phy_state], in be_log_sfp_info()
5491 adapter->phy.vendor_name, in be_log_sfp_info()
5492 adapter->phy.vendor_pn); in be_log_sfp_info()
5494 adapter->flags &= ~BE_FLAGS_PHY_MISCONFIGURED; in be_log_sfp_info()
5505 MODULO(adapter->work_counter, adapter->be_get_temp_freq) == 0) in be_worker()
5511 if (!netif_running(adapter->netdev)) { in be_worker()
5516 if (!adapter->stats_cmd_sent) { in be_worker()
5519 &adapter->stats_cmd); in be_worker()
5521 be_cmd_get_stats(adapter, &adapter->stats_cmd); in be_worker()
5525 /* Replenish RX-queues starved due to memory in be_worker()
5528 if (rxo->rx_post_starved) in be_worker()
5532 /* EQ-delay update for Skyhawk is done while notifying EQ */ in be_worker()
5536 if (adapter->flags & BE_FLAGS_PHY_MISCONFIGURED) in be_worker()
5540 adapter->work_counter++; in be_worker()
5541 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_worker()
5546 if (adapter->csr) in be_unmap_pci_bars()
5547 pci_iounmap(adapter->pdev, adapter->csr); in be_unmap_pci_bars()
5548 if (adapter->db) in be_unmap_pci_bars()
5549 pci_iounmap(adapter->pdev, adapter->db); in be_unmap_pci_bars()
5550 if (adapter->pcicfg && adapter->pcicfg_mapped) in be_unmap_pci_bars()
5551 pci_iounmap(adapter->pdev, adapter->pcicfg); in be_unmap_pci_bars()
5565 adapter->roce_db.size = 4096; in be_roce_map_pci_bars()
5566 adapter->roce_db.io_addr = pci_resource_start(adapter->pdev, in be_roce_map_pci_bars()
5568 adapter->roce_db.total_size = pci_resource_len(adapter->pdev, in be_roce_map_pci_bars()
5576 struct pci_dev *pdev = adapter->pdev; in be_map_pci_bars()
5580 pci_read_config_dword(adapter->pdev, SLI_INTF_REG_OFFSET, &sli_intf); in be_map_pci_bars()
5581 adapter->sli_family = (sli_intf & SLI_INTF_FAMILY_MASK) >> in be_map_pci_bars()
5583 adapter->virtfn = (sli_intf & SLI_INTF_FT_MASK) ? 1 : 0; in be_map_pci_bars()
5586 adapter->csr = pci_iomap(pdev, 2, 0); in be_map_pci_bars()
5587 if (!adapter->csr) in be_map_pci_bars()
5588 return -ENOMEM; in be_map_pci_bars()
5594 adapter->db = addr; in be_map_pci_bars()
5602 adapter->pcicfg = addr; in be_map_pci_bars()
5603 adapter->pcicfg_mapped = true; in be_map_pci_bars()
5605 adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET; in be_map_pci_bars()
5606 adapter->pcicfg_mapped = false; in be_map_pci_bars()
5614 dev_err(&pdev->dev, "Error in mapping PCI BARs\n"); in be_map_pci_bars()
5616 return -ENOMEM; in be_map_pci_bars()
5621 struct be_dma_mem *mem = &adapter->mbox_mem_alloced; in be_drv_cleanup()
5622 struct device *dev = &adapter->pdev->dev; in be_drv_cleanup()
5624 if (mem->va) in be_drv_cleanup()
5625 dma_free_coherent(dev, mem->size, mem->va, mem->dma); in be_drv_cleanup()
5627 mem = &adapter->rx_filter; in be_drv_cleanup()
5628 if (mem->va) in be_drv_cleanup()
5629 dma_free_coherent(dev, mem->size, mem->va, mem->dma); in be_drv_cleanup()
5631 mem = &adapter->stats_cmd; in be_drv_cleanup()
5632 if (mem->va) in be_drv_cleanup()
5633 dma_free_coherent(dev, mem->size, mem->va, mem->dma); in be_drv_cleanup()
5639 struct be_dma_mem *mbox_mem_alloc = &adapter->mbox_mem_alloced; in be_drv_init()
5640 struct be_dma_mem *mbox_mem_align = &adapter->mbox_mem; in be_drv_init()
5641 struct be_dma_mem *rx_filter = &adapter->rx_filter; in be_drv_init()
5642 struct be_dma_mem *stats_cmd = &adapter->stats_cmd; in be_drv_init()
5643 struct device *dev = &adapter->pdev->dev; in be_drv_init()
5646 mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16; in be_drv_init()
5647 mbox_mem_alloc->va = dma_alloc_coherent(dev, mbox_mem_alloc->size, in be_drv_init()
5648 &mbox_mem_alloc->dma, in be_drv_init()
5650 if (!mbox_mem_alloc->va) in be_drv_init()
5651 return -ENOMEM; in be_drv_init()
5653 mbox_mem_align->size = sizeof(struct be_mcc_mailbox); in be_drv_init()
5654 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); in be_drv_init()
5655 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); in be_drv_init()
5657 rx_filter->size = sizeof(struct be_cmd_req_rx_filter); in be_drv_init()
5658 rx_filter->va = dma_alloc_coherent(dev, rx_filter->size, in be_drv_init()
5659 &rx_filter->dma, GFP_KERNEL); in be_drv_init()
5660 if (!rx_filter->va) { in be_drv_init()
5661 status = -ENOMEM; in be_drv_init()
5666 stats_cmd->size = sizeof(struct lancer_cmd_req_pport_stats); in be_drv_init()
5668 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v0); in be_drv_init()
5670 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v1); in be_drv_init()
5672 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v2); in be_drv_init()
5673 stats_cmd->va = dma_alloc_coherent(dev, stats_cmd->size, in be_drv_init()
5674 &stats_cmd->dma, GFP_KERNEL); in be_drv_init()
5675 if (!stats_cmd->va) { in be_drv_init()
5676 status = -ENOMEM; in be_drv_init()
5680 mutex_init(&adapter->mbox_lock); in be_drv_init()
5681 mutex_init(&adapter->mcc_lock); in be_drv_init()
5682 mutex_init(&adapter->rx_filter_lock); in be_drv_init()
5683 spin_lock_init(&adapter->mcc_cq_lock); in be_drv_init()
5684 init_completion(&adapter->et_cmd_compl); in be_drv_init()
5686 pci_save_state(adapter->pdev); in be_drv_init()
5688 INIT_DELAYED_WORK(&adapter->work, be_worker); in be_drv_init()
5690 adapter->error_recovery.recovery_state = ERR_RECOVERY_ST_NONE; in be_drv_init()
5691 adapter->error_recovery.resched_delay = 0; in be_drv_init()
5692 INIT_DELAYED_WORK(&adapter->error_recovery.err_detection_work, in be_drv_init()
5695 adapter->rx_fc = true; in be_drv_init()
5696 adapter->tx_fc = true; in be_drv_init()
5699 adapter->be_get_temp_freq = 64; in be_drv_init()
5704 dma_free_coherent(dev, rx_filter->size, rx_filter->va, rx_filter->dma); in be_drv_init()
5706 dma_free_coherent(dev, mbox_mem_alloc->size, mbox_mem_alloc->va, in be_drv_init()
5707 mbox_mem_alloc->dma); in be_drv_init()
5723 unregister_netdev(adapter->netdev); in be_remove()
5727 if (!pci_vfs_assigned(adapter->pdev)) in be_remove()
5741 free_netdev(adapter->netdev); in be_remove()
5751 if (adapter->hwmon_info.be_on_die_temp == BE_INVALID_DIE_TEMP) in be_hwmon_show_temp()
5752 return -EIO; in be_hwmon_show_temp()
5755 adapter->hwmon_info.be_on_die_temp * 1000); in be_hwmon_show_temp()
5772 switch (adapter->mc_type) { in mc_name()
5780 str = "vNIC-1"; in mc_name()
5789 str = "vNIC-2"; in mc_name()
5805 switch (pdev->device) { in nic_name()
5840 status = -ENOMEM; in be_probe()
5844 adapter->pdev = pdev; in be_probe()
5846 adapter->netdev = netdev; in be_probe()
5847 SET_NETDEV_DEV(netdev, &pdev->dev); in be_probe()
5849 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in be_probe()
5851 netdev->features |= NETIF_F_HIGHDMA; in be_probe()
5853 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in be_probe()
5855 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n"); in be_probe()
5862 dev_info(&pdev->dev, "PCIe error reporting enabled\n"); in be_probe()
5884 adapter->error_recovery.probe_time = jiffies; in be_probe()
5888 adapter->hwmon_info.hwmon_dev = in be_probe()
5889 devm_hwmon_device_register_with_groups(&pdev->dev, in be_probe()
5893 adapter->hwmon_info.be_on_die_temp = BE_INVALID_DIE_TEMP; in be_probe()
5896 dev_info(&pdev->dev, "%s: %s %s port %c\n", nic_name(pdev), in be_probe()
5897 func_name(adapter), mc_name(adapter), adapter->port_name); in be_probe()
5914 dev_err(&pdev->dev, "%s initialization failed\n", nic_name(pdev)); in be_probe()
5955 cancel_delayed_work_sync(&adapter->work); in be_shutdown()
5958 netif_device_detach(adapter->netdev); in be_shutdown()
5970 dev_err(&adapter->pdev->dev, "EEH error detected\n"); in be_eeh_err_detected()
5993 if (pdev->devfn == 0) in be_eeh_err_detected()
6004 dev_info(&adapter->pdev->dev, "EEH reset\n"); in be_eeh_reset()
6014 dev_info(&adapter->pdev->dev, in be_eeh_reset()
6029 dev_info(&adapter->pdev->dev, "EEH resume\n"); in be_eeh_resume()
6042 dev_err(&adapter->pdev->dev, "EEH resume failed\n"); in be_eeh_resume()
6054 adapter->num_vfs = num_vfs; in be_pci_sriov_configure()
6056 if (adapter->num_vfs == 0 && pci_vfs_assigned(pdev)) { in be_pci_sriov_configure()
6057 dev_warn(&pdev->dev, in be_pci_sriov_configure()
6059 return -EBUSY; in be_pci_sriov_configure()
6062 /* When the HW is in SRIOV capable configuration, the PF-pool resources in be_pci_sriov_configure()
6063 * are equally distributed across the max-number of VFs. The user may in be_pci_sriov_configure()
6064 * request only a subset of the max-vfs to be enabled. in be_pci_sriov_configure()
6071 be_calculate_vf_res(adapter, adapter->num_vfs, in be_pci_sriov_configure()
6073 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_pci_sriov_configure()
6074 adapter->num_vfs, &vft_res); in be_pci_sriov_configure()
6076 dev_err(&pdev->dev, in be_pci_sriov_configure()
6077 "Failed to optimize SR-IOV resources\n"); in be_pci_sriov_configure()
6091 if (adapter->num_vfs) in be_pci_sriov_configure()
6095 return adapter->num_vfs; in be_pci_sriov_configure()
6139 return -1; in be_init_module()