Lines Matching +full:pci +full:- +full:host2

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005 - 2016 Broadcom
7 * linux-drivers@emulex.com
32 MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize");
38 /* Per-module error detection/recovery workq shared across all functions.
62 MODULE_DEVICE_TABLE(pci, be_dev_ids);
120 "HOST2",
146 struct be_dma_mem *mem = &q->dma_mem; in be_queue_free()
148 if (mem->va) { in be_queue_free()
149 dma_free_coherent(&adapter->pdev->dev, mem->size, mem->va, in be_queue_free()
150 mem->dma); in be_queue_free()
151 mem->va = NULL; in be_queue_free()
158 struct be_dma_mem *mem = &q->dma_mem; in be_queue_alloc()
161 q->len = len; in be_queue_alloc()
162 q->entry_size = entry_size; in be_queue_alloc()
163 mem->size = len * entry_size; in be_queue_alloc()
164 mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, in be_queue_alloc()
165 &mem->dma, GFP_KERNEL); in be_queue_alloc()
166 if (!mem->va) in be_queue_alloc()
167 return -ENOMEM; in be_queue_alloc()
175 pci_read_config_dword(adapter->pdev, PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET, in be_reg_intr_set()
186 pci_write_config_dword(adapter->pdev, in be_reg_intr_set()
217 iowrite32(val, adapter->db + DB_RQ_OFFSET); in be_rxq_notify()
228 val |= txo->q.id & DB_TXULP_RING_ID_MASK; in be_txq_notify()
232 iowrite32(val, adapter->db + txo->db_offset); in be_txq_notify()
254 iowrite32(val, adapter->db + DB_EQ_OFFSET); in be_eq_notify()
271 iowrite32(val, adapter->db + DB_CQ_OFFSET); in be_cq_notify()
278 /* Check if mac has already been added as part of uc-list */ in be_dev_mac_add()
279 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_add()
280 if (ether_addr_equal(adapter->uc_list[i].mac, mac)) { in be_dev_mac_add()
282 adapter->pmac_id[0] = adapter->pmac_id[i + 1]; in be_dev_mac_add()
287 return be_cmd_pmac_add(adapter, mac, adapter->if_handle, in be_dev_mac_add()
288 &adapter->pmac_id[0], 0); in be_dev_mac_add()
296 * being used in uc-list in be_dev_mac_del()
298 for (i = 0; i < adapter->uc_macs; i++) { in be_dev_mac_del()
299 if (adapter->pmac_id[i + 1] == pmac_id) in be_dev_mac_del()
302 be_cmd_pmac_del(adapter, adapter->if_handle, pmac_id, 0); in be_dev_mac_del()
308 struct device *dev = &adapter->pdev->dev; in be_mac_addr_set()
312 u32 old_pmac_id = adapter->pmac_id[0]; in be_mac_addr_set()
314 if (!is_valid_ether_addr(addr->sa_data)) in be_mac_addr_set()
315 return -EADDRNOTAVAIL; in be_mac_addr_set()
320 if (ether_addr_equal(addr->sa_data, adapter->dev_mac)) in be_mac_addr_set()
328 return -EPERM; in be_mac_addr_set()
330 /* if device is not running, copy MAC to netdev->dev_addr */ in be_mac_addr_set()
340 mutex_lock(&adapter->rx_filter_lock); in be_mac_addr_set()
341 status = be_dev_mac_add(adapter, (u8 *)addr->sa_data); in be_mac_addr_set()
347 if (adapter->pmac_id[0] != old_pmac_id) in be_mac_addr_set()
351 mutex_unlock(&adapter->rx_filter_lock); in be_mac_addr_set()
355 status = be_cmd_get_active_mac(adapter, adapter->pmac_id[0], mac, in be_mac_addr_set()
356 adapter->if_handle, true, 0); in be_mac_addr_set()
361 * or PF didn't pre-provision. in be_mac_addr_set()
363 if (!ether_addr_equal(addr->sa_data, mac)) { in be_mac_addr_set()
364 status = -EPERM; in be_mac_addr_set()
369 ether_addr_copy(adapter->dev_mac, addr->sa_data); in be_mac_addr_set()
371 eth_hw_addr_set(netdev, addr->sa_data); in be_mac_addr_set()
372 dev_info(dev, "MAC address changed to %pM\n", addr->sa_data); in be_mac_addr_set()
375 dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data); in be_mac_addr_set()
383 struct be_cmd_resp_get_stats_v0 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
385 return &cmd->hw_stats; in hw_stats_from_cmd()
387 struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
389 return &cmd->hw_stats; in hw_stats_from_cmd()
391 struct be_cmd_resp_get_stats_v2 *cmd = adapter->stats_cmd.va; in hw_stats_from_cmd()
393 return &cmd->hw_stats; in hw_stats_from_cmd()
403 return &hw_stats->erx; in be_erx_stats_from_cmd()
407 return &hw_stats->erx; in be_erx_stats_from_cmd()
411 return &hw_stats->erx; in be_erx_stats_from_cmd()
418 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v0_stats()
419 struct be_rxf_stats_v0 *rxf_stats = &hw_stats->rxf; in populate_be_v0_stats()
421 &rxf_stats->port[adapter->port_num]; in populate_be_v0_stats()
422 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v0_stats()
425 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v0_stats()
426 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v0_stats()
427 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v0_stats()
428 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v0_stats()
429 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v0_stats()
430 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v0_stats()
431 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v0_stats()
432 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v0_stats()
433 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v0_stats()
434 drvs->rxpp_fifo_overflow_drop = port_stats->rx_fifo_overflow; in populate_be_v0_stats()
435 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v0_stats()
436 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v0_stats()
437 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v0_stats()
438 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v0_stats()
439 drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow; in populate_be_v0_stats()
440 drvs->rx_dropped_header_too_small = in populate_be_v0_stats()
441 port_stats->rx_dropped_header_too_small; in populate_be_v0_stats()
442 drvs->rx_address_filtered = in populate_be_v0_stats()
443 port_stats->rx_address_filtered + in populate_be_v0_stats()
444 port_stats->rx_vlan_filtered; in populate_be_v0_stats()
445 drvs->rx_alignment_symbol_errors = in populate_be_v0_stats()
446 port_stats->rx_alignment_symbol_errors; in populate_be_v0_stats()
448 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v0_stats()
449 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v0_stats()
451 if (adapter->port_num) in populate_be_v0_stats()
452 drvs->jabber_events = rxf_stats->port1_jabber_events; in populate_be_v0_stats()
454 drvs->jabber_events = rxf_stats->port0_jabber_events; in populate_be_v0_stats()
455 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v0_stats()
456 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v0_stats()
457 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v0_stats()
458 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v0_stats()
459 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v0_stats()
460 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v0_stats()
461 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v0_stats()
467 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v1_stats()
468 struct be_rxf_stats_v1 *rxf_stats = &hw_stats->rxf; in populate_be_v1_stats()
470 &rxf_stats->port[adapter->port_num]; in populate_be_v1_stats()
471 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v1_stats()
474 drvs->pmem_fifo_overflow_drop = port_stats->pmem_fifo_overflow_drop; in populate_be_v1_stats()
475 drvs->rx_priority_pause_frames = port_stats->rx_priority_pause_frames; in populate_be_v1_stats()
476 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v1_stats()
477 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v1_stats()
478 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v1_stats()
479 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v1_stats()
480 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v1_stats()
481 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v1_stats()
482 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v1_stats()
483 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v1_stats()
484 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v1_stats()
485 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v1_stats()
486 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v1_stats()
487 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v1_stats()
488 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v1_stats()
489 drvs->rx_dropped_header_too_small = in populate_be_v1_stats()
490 port_stats->rx_dropped_header_too_small; in populate_be_v1_stats()
491 drvs->rx_input_fifo_overflow_drop = in populate_be_v1_stats()
492 port_stats->rx_input_fifo_overflow_drop; in populate_be_v1_stats()
493 drvs->rx_address_filtered = port_stats->rx_address_filtered; in populate_be_v1_stats()
494 drvs->rx_alignment_symbol_errors = in populate_be_v1_stats()
495 port_stats->rx_alignment_symbol_errors; in populate_be_v1_stats()
496 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; in populate_be_v1_stats()
497 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v1_stats()
498 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v1_stats()
499 drvs->tx_priority_pauseframes = port_stats->tx_priority_pauseframes; in populate_be_v1_stats()
500 drvs->jabber_events = port_stats->jabber_events; in populate_be_v1_stats()
501 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v1_stats()
502 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v1_stats()
503 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v1_stats()
504 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v1_stats()
505 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v1_stats()
506 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v1_stats()
507 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v1_stats()
513 struct be_pmem_stats *pmem_sts = &hw_stats->pmem; in populate_be_v2_stats()
514 struct be_rxf_stats_v2 *rxf_stats = &hw_stats->rxf; in populate_be_v2_stats()
516 &rxf_stats->port[adapter->port_num]; in populate_be_v2_stats()
517 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_be_v2_stats()
520 drvs->pmem_fifo_overflow_drop = port_stats->pmem_fifo_overflow_drop; in populate_be_v2_stats()
521 drvs->rx_priority_pause_frames = port_stats->rx_priority_pause_frames; in populate_be_v2_stats()
522 drvs->rx_pause_frames = port_stats->rx_pause_frames; in populate_be_v2_stats()
523 drvs->rx_crc_errors = port_stats->rx_crc_errors; in populate_be_v2_stats()
524 drvs->rx_control_frames = port_stats->rx_control_frames; in populate_be_v2_stats()
525 drvs->rx_in_range_errors = port_stats->rx_in_range_errors; in populate_be_v2_stats()
526 drvs->rx_frame_too_long = port_stats->rx_frame_too_long; in populate_be_v2_stats()
527 drvs->rx_dropped_runt = port_stats->rx_dropped_runt; in populate_be_v2_stats()
528 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs; in populate_be_v2_stats()
529 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs; in populate_be_v2_stats()
530 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs; in populate_be_v2_stats()
531 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length; in populate_be_v2_stats()
532 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small; in populate_be_v2_stats()
533 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short; in populate_be_v2_stats()
534 drvs->rx_out_range_errors = port_stats->rx_out_range_errors; in populate_be_v2_stats()
535 drvs->rx_dropped_header_too_small = in populate_be_v2_stats()
536 port_stats->rx_dropped_header_too_small; in populate_be_v2_stats()
537 drvs->rx_input_fifo_overflow_drop = in populate_be_v2_stats()
538 port_stats->rx_input_fifo_overflow_drop; in populate_be_v2_stats()
539 drvs->rx_address_filtered = port_stats->rx_address_filtered; in populate_be_v2_stats()
540 drvs->rx_alignment_symbol_errors = in populate_be_v2_stats()
541 port_stats->rx_alignment_symbol_errors; in populate_be_v2_stats()
542 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; in populate_be_v2_stats()
543 drvs->tx_pauseframes = port_stats->tx_pauseframes; in populate_be_v2_stats()
544 drvs->tx_controlframes = port_stats->tx_controlframes; in populate_be_v2_stats()
545 drvs->tx_priority_pauseframes = port_stats->tx_priority_pauseframes; in populate_be_v2_stats()
546 drvs->jabber_events = port_stats->jabber_events; in populate_be_v2_stats()
547 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; in populate_be_v2_stats()
548 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; in populate_be_v2_stats()
549 drvs->forwarded_packets = rxf_stats->forwarded_packets; in populate_be_v2_stats()
550 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; in populate_be_v2_stats()
551 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; in populate_be_v2_stats()
552 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags; in populate_be_v2_stats()
553 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; in populate_be_v2_stats()
555 drvs->rx_roce_bytes_lsd = port_stats->roce_bytes_received_lsd; in populate_be_v2_stats()
556 drvs->rx_roce_bytes_msd = port_stats->roce_bytes_received_msd; in populate_be_v2_stats()
557 drvs->rx_roce_frames = port_stats->roce_frames_received; in populate_be_v2_stats()
558 drvs->roce_drops_crc = port_stats->roce_drops_crc; in populate_be_v2_stats()
559 drvs->roce_drops_payload_len = in populate_be_v2_stats()
560 port_stats->roce_drops_payload_len; in populate_be_v2_stats()
566 struct be_drv_stats *drvs = &adapter->drv_stats; in populate_lancer_stats()
570 drvs->rx_pause_frames = pport_stats->rx_pause_frames_lo; in populate_lancer_stats()
571 drvs->rx_crc_errors = pport_stats->rx_crc_errors_lo; in populate_lancer_stats()
572 drvs->rx_control_frames = pport_stats->rx_control_frames_lo; in populate_lancer_stats()
573 drvs->rx_in_range_errors = pport_stats->rx_in_range_errors; in populate_lancer_stats()
574 drvs->rx_frame_too_long = pport_stats->rx_frames_too_long_lo; in populate_lancer_stats()
575 drvs->rx_dropped_runt = pport_stats->rx_dropped_runt; in populate_lancer_stats()
576 drvs->rx_ip_checksum_errs = pport_stats->rx_ip_checksum_errors; in populate_lancer_stats()
577 drvs->rx_tcp_checksum_errs = pport_stats->rx_tcp_checksum_errors; in populate_lancer_stats()
578 drvs->rx_udp_checksum_errs = pport_stats->rx_udp_checksum_errors; in populate_lancer_stats()
579 drvs->rx_dropped_tcp_length = in populate_lancer_stats()
580 pport_stats->rx_dropped_invalid_tcp_length; in populate_lancer_stats()
581 drvs->rx_dropped_too_small = pport_stats->rx_dropped_too_small; in populate_lancer_stats()
582 drvs->rx_dropped_too_short = pport_stats->rx_dropped_too_short; in populate_lancer_stats()
583 drvs->rx_out_range_errors = pport_stats->rx_out_of_range_errors; in populate_lancer_stats()
584 drvs->rx_dropped_header_too_small = in populate_lancer_stats()
585 pport_stats->rx_dropped_header_too_small; in populate_lancer_stats()
586 drvs->rx_input_fifo_overflow_drop = pport_stats->rx_fifo_overflow; in populate_lancer_stats()
587 drvs->rx_address_filtered = in populate_lancer_stats()
588 pport_stats->rx_address_filtered + in populate_lancer_stats()
589 pport_stats->rx_vlan_filtered; in populate_lancer_stats()
590 drvs->rx_alignment_symbol_errors = pport_stats->rx_symbol_errors_lo; in populate_lancer_stats()
591 drvs->rxpp_fifo_overflow_drop = pport_stats->rx_fifo_overflow; in populate_lancer_stats()
592 drvs->tx_pauseframes = pport_stats->tx_pause_frames_lo; in populate_lancer_stats()
593 drvs->tx_controlframes = pport_stats->tx_control_frames_lo; in populate_lancer_stats()
594 drvs->jabber_events = pport_stats->rx_jabbers; in populate_lancer_stats()
595 drvs->forwarded_packets = pport_stats->num_forwards_lo; in populate_lancer_stats()
596 drvs->rx_drops_mtu = pport_stats->rx_drops_mtu_lo; in populate_lancer_stats()
597 drvs->rx_drops_too_many_frags = in populate_lancer_stats()
598 pport_stats->rx_drops_too_many_frags_lo; in populate_lancer_stats()
617 rx_stats(rxo)->rx_drops_no_frags = erx_stat; in populate_erx_stats()
620 * 65535. Driver accumulates a 32-bit value in populate_erx_stats()
622 accumulate_16bit_val(&rx_stats(rxo)->rx_drops_no_frags, in populate_erx_stats()
646 erx_stat = erx->rx_drops_no_fragments[rxo->q.id]; in be_parse_stats()
656 struct be_drv_stats *drvs = &adapter->drv_stats; in be_get_stats64()
667 start = u64_stats_fetch_begin(&rx_stats->sync); in be_get_stats64()
668 pkts = rx_stats(rxo)->rx_pkts; in be_get_stats64()
669 bytes = rx_stats(rxo)->rx_bytes; in be_get_stats64()
670 } while (u64_stats_fetch_retry(&rx_stats->sync, start)); in be_get_stats64()
671 stats->rx_packets += pkts; in be_get_stats64()
672 stats->rx_bytes += bytes; in be_get_stats64()
673 stats->multicast += rx_stats(rxo)->rx_mcast_pkts; in be_get_stats64()
674 stats->rx_dropped += rx_stats(rxo)->rx_drops_no_skbs + in be_get_stats64()
675 rx_stats(rxo)->rx_drops_no_frags; in be_get_stats64()
682 start = u64_stats_fetch_begin(&tx_stats->sync); in be_get_stats64()
683 pkts = tx_stats(txo)->tx_pkts; in be_get_stats64()
684 bytes = tx_stats(txo)->tx_bytes; in be_get_stats64()
685 } while (u64_stats_fetch_retry(&tx_stats->sync, start)); in be_get_stats64()
686 stats->tx_packets += pkts; in be_get_stats64()
687 stats->tx_bytes += bytes; in be_get_stats64()
691 stats->rx_errors = drvs->rx_crc_errors + in be_get_stats64()
692 drvs->rx_alignment_symbol_errors + in be_get_stats64()
693 drvs->rx_in_range_errors + in be_get_stats64()
694 drvs->rx_out_range_errors + in be_get_stats64()
695 drvs->rx_frame_too_long + in be_get_stats64()
696 drvs->rx_dropped_too_small + in be_get_stats64()
697 drvs->rx_dropped_too_short + in be_get_stats64()
698 drvs->rx_dropped_header_too_small + in be_get_stats64()
699 drvs->rx_dropped_tcp_length + in be_get_stats64()
700 drvs->rx_dropped_runt; in be_get_stats64()
703 stats->rx_length_errors = drvs->rx_in_range_errors + in be_get_stats64()
704 drvs->rx_out_range_errors + in be_get_stats64()
705 drvs->rx_frame_too_long; in be_get_stats64()
707 stats->rx_crc_errors = drvs->rx_crc_errors; in be_get_stats64()
710 stats->rx_frame_errors = drvs->rx_alignment_symbol_errors; in be_get_stats64()
714 stats->rx_fifo_errors = drvs->rxpp_fifo_overflow_drop + in be_get_stats64()
715 drvs->rx_input_fifo_overflow_drop + in be_get_stats64()
716 drvs->rx_drops_no_pbuf; in be_get_stats64()
721 struct net_device *netdev = adapter->netdev; in be_link_status_update()
723 if (!(adapter->flags & BE_FLAGS_LINK_STATUS_INIT)) { in be_link_status_update()
725 adapter->flags |= BE_FLAGS_LINK_STATUS_INIT; in be_link_status_update()
738 if (skb->encapsulation) in be_gso_hdr_len()
747 u32 tx_pkts = skb_shinfo(skb)->gso_segs ? : 1; in be_tx_stats_update()
749 u32 dup_hdr_len = tx_pkts > 1 ? be_gso_hdr_len(skb) * (tx_pkts - 1) : 0; in be_tx_stats_update()
751 u64_stats_update_begin(&stats->sync); in be_tx_stats_update()
752 stats->tx_reqs++; in be_tx_stats_update()
753 stats->tx_bytes += skb->len + dup_hdr_len; in be_tx_stats_update()
754 stats->tx_pkts += tx_pkts; in be_tx_stats_update()
755 if (skb->encapsulation && skb->ip_summed == CHECKSUM_PARTIAL) in be_tx_stats_update()
756 stats->tx_vxlan_offload_pkts += tx_pkts; in be_tx_stats_update()
757 u64_stats_update_end(&stats->sync); in be_tx_stats_update()
764 return 1 + (skb_headlen(skb) ? 1 : 0) + skb_shinfo(skb)->nr_frags; in skb_wrb_cnt()
769 wrb->frag_pa_hi = cpu_to_le32(upper_32_bits(addr)); in wrb_fill()
770 wrb->frag_pa_lo = cpu_to_le32(lower_32_bits(addr)); in wrb_fill()
771 wrb->frag_len = cpu_to_le32(len & ETH_WRB_FRAG_LEN_MASK); in wrb_fill()
772 wrb->rsvd0 = 0; in wrb_fill()
775 /* A dummy wrb is just all zeros. Using a separate routine for dummy-wrb
780 wrb->frag_pa_hi = 0; in wrb_fill_dummy()
781 wrb->frag_pa_lo = 0; in wrb_fill_dummy()
782 wrb->frag_len = 0; in wrb_fill_dummy()
783 wrb->rsvd0 = 0; in wrb_fill_dummy()
795 if (!(adapter->vlan_prio_bmap & (1 << vlan_prio))) in be_get_tx_vlan_tag()
797 adapter->recommended_prio_bits; in be_get_tx_vlan_tag()
805 return (inner_ip_hdr(skb)->version == 4) ? in skb_inner_ip_proto()
806 inner_ip_hdr(skb)->protocol : inner_ipv6_hdr(skb)->nexthdr; in skb_inner_ip_proto()
811 return (ip_hdr(skb)->version == 4) ? in skb_ip_proto()
812 ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr; in skb_ip_proto()
817 return atomic_read(&txo->q.used) + BE_MAX_TX_FRAG_COUNT >= txo->q.len; in be_is_txq_full()
822 return atomic_read(&txo->q.used) < txo->q.len / 2; in be_can_txq_wake()
827 return atomic_read(&txo->q.used) > txo->pend_wrb_cnt; in be_is_tx_compl_pending()
837 BE_WRB_F_SET(wrb_params->features, LSO, 1); in be_get_wrb_params_from_skb()
838 wrb_params->lso_mss = skb_shinfo(skb)->gso_size; in be_get_wrb_params_from_skb()
840 BE_WRB_F_SET(wrb_params->features, LSO6, 1); in be_get_wrb_params_from_skb()
841 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { in be_get_wrb_params_from_skb()
842 if (skb->encapsulation) { in be_get_wrb_params_from_skb()
843 BE_WRB_F_SET(wrb_params->features, IPCS, 1); in be_get_wrb_params_from_skb()
849 BE_WRB_F_SET(wrb_params->features, TCPCS, 1); in be_get_wrb_params_from_skb()
851 BE_WRB_F_SET(wrb_params->features, UDPCS, 1); in be_get_wrb_params_from_skb()
855 BE_WRB_F_SET(wrb_params->features, VLAN, 1); in be_get_wrb_params_from_skb()
856 wrb_params->vlan_tag = be_get_tx_vlan_tag(adapter, skb); in be_get_wrb_params_from_skb()
859 BE_WRB_F_SET(wrb_params->features, CRC, 1); in be_get_wrb_params_from_skb()
870 BE_WRB_F_GET(wrb_params->features, CRC)); in wrb_fill_hdr()
872 BE_WRB_F_GET(wrb_params->features, IPCS)); in wrb_fill_hdr()
874 BE_WRB_F_GET(wrb_params->features, TCPCS)); in wrb_fill_hdr()
876 BE_WRB_F_GET(wrb_params->features, UDPCS)); in wrb_fill_hdr()
879 BE_WRB_F_GET(wrb_params->features, LSO)); in wrb_fill_hdr()
881 BE_WRB_F_GET(wrb_params->features, LSO6)); in wrb_fill_hdr()
882 SET_TX_WRB_HDR_BITS(lso_mss, hdr, wrb_params->lso_mss); in wrb_fill_hdr()
888 BE_WRB_F_GET(wrb_params->features, VLAN_SKIP_HW)); in wrb_fill_hdr()
890 BE_WRB_F_GET(wrb_params->features, VLAN)); in wrb_fill_hdr()
891 SET_TX_WRB_HDR_BITS(vlan_tag, hdr, wrb_params->vlan_tag); in wrb_fill_hdr()
894 SET_TX_WRB_HDR_BITS(len, hdr, skb->len); in wrb_fill_hdr()
896 BE_WRB_F_GET(wrb_params->features, OS2BMC)); in wrb_fill_hdr()
903 u32 frag_len = le32_to_cpu(wrb->frag_len); in unmap_tx_frag()
906 dma = (u64)le32_to_cpu(wrb->frag_pa_hi) << 32 | in unmap_tx_frag()
907 (u64)le32_to_cpu(wrb->frag_pa_lo); in unmap_tx_frag()
919 u32 head = txo->q.head; in be_tx_get_wrb_hdr()
921 queue_head_inc(&txo->q); in be_tx_get_wrb_hdr()
932 struct be_queue_info *txq = &txo->q; in be_tx_setup_wrb_hdr()
938 BUG_ON(txo->sent_skb_list[head]); in be_tx_setup_wrb_hdr()
939 txo->sent_skb_list[head] = skb; in be_tx_setup_wrb_hdr()
940 txo->last_req_hdr = head; in be_tx_setup_wrb_hdr()
941 atomic_add(num_frags, &txq->used); in be_tx_setup_wrb_hdr()
942 txo->last_req_wrb_cnt = num_frags; in be_tx_setup_wrb_hdr()
943 txo->pend_wrb_cnt += num_frags; in be_tx_setup_wrb_hdr()
951 struct be_queue_info *txq = &txo->q; in be_tx_setup_wrb_frag()
968 struct be_queue_info *txq = &txo->q; in be_xmit_restore()
970 dev = &adapter->pdev->dev; in be_xmit_restore()
971 txq->head = head; in be_xmit_restore()
979 copied -= le32_to_cpu(wrb->frag_len); in be_xmit_restore()
983 txq->head = head; in be_xmit_restore()
995 struct device *dev = &adapter->pdev->dev; in be_xmit_enqueue()
1003 if (skb->len > skb->data_len) { in be_xmit_enqueue()
1006 busaddr = dma_map_single(dev, skb->data, len, DMA_TO_DEVICE); in be_xmit_enqueue()
1014 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in be_xmit_enqueue()
1015 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in be_xmit_enqueue()
1031 adapter->drv_stats.dma_map_errors++; in be_xmit_enqueue()
1038 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; in qnq_async_evt_rcvd()
1058 if (qnq_async_evt_rcvd(adapter) && adapter->pvid) { in be_insert_vlan_in_pkt()
1060 vlan_tag = adapter->pvid; in be_insert_vlan_in_pkt()
1066 BE_WRB_F_SET(wrb_params->features, VLAN_SKIP_HW, 1); in be_insert_vlan_in_pkt()
1078 if (adapter->qnq_vid) { in be_insert_vlan_in_pkt()
1079 vlan_tag = adapter->qnq_vid; in be_insert_vlan_in_pkt()
1084 BE_WRB_F_SET(wrb_params->features, VLAN_SKIP_HW, 1); in be_insert_vlan_in_pkt()
1092 struct ethhdr *eh = (struct ethhdr *)skb->data; in be_ipv6_exthdr_check()
1095 if (eh->h_proto == htons(ETH_P_IPV6)) { in be_ipv6_exthdr_check()
1096 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + offset); in be_ipv6_exthdr_check()
1099 if (ip6h->nexthdr != NEXTHDR_TCP && in be_ipv6_exthdr_check()
1100 ip6h->nexthdr != NEXTHDR_UDP) { in be_ipv6_exthdr_check()
1102 (struct ipv6_opt_hdr *)(skb->data + offset); in be_ipv6_exthdr_check()
1105 if (ehdr->hdrlen == 0xff) in be_ipv6_exthdr_check()
1114 return skb_vlan_tag_present(skb) || adapter->pvid || adapter->qnq_vid; in be_vlan_tag_tx_chk()
1135 eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ? in be_lancer_xmit_workarounds()
1137 if (skb->len <= 60 && in be_lancer_xmit_workarounds()
1141 if (unlikely(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()
1401 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(&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(&rxo->stats.sync, start)); in be_get_new_eqd()
2165 start = u64_stats_fetch_begin(&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(&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()
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_fill_page_desc(&skb_shinfo(skb)->frags[0], in skb_fill_rx_data()
2348 page_info->page, in skb_fill_rx_data()
2349 page_info->page_offset + hdr_len, in skb_fill_rx_data()
2350 curr_frag_len - hdr_len); in skb_fill_rx_data()
2351 skb->data_len = curr_frag_len - hdr_len; in skb_fill_rx_data()
2352 skb->truesize += rx_frag_size; in skb_fill_rx_data()
2353 skb->tail += hdr_len; in skb_fill_rx_data()
2355 page_info->page = NULL; in skb_fill_rx_data()
2357 if (rxcp->pkt_size <= rx_frag_size) { in skb_fill_rx_data()
2358 BUG_ON(rxcp->num_rcvd != 1); in skb_fill_rx_data()
2363 remaining = rxcp->pkt_size - curr_frag_len; in skb_fill_rx_data()
2364 for (i = 1, j = 0; i < rxcp->num_rcvd; i++) { in skb_fill_rx_data()
2369 if (page_info->page_offset == 0) { in skb_fill_rx_data()
2372 skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[j], in skb_fill_rx_data()
2373 page_info->page, in skb_fill_rx_data()
2374 page_info->page_offset, in skb_fill_rx_data()
2376 skb_shinfo(skb)->nr_frags++; in skb_fill_rx_data()
2378 put_page(page_info->page); in skb_fill_rx_data()
2379 skb_frag_size_add(&skb_shinfo(skb)->frags[j], 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()
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()
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_fill_page_desc(&skb_shinfo(skb)->frags[j], in be_rx_compl_process_gro()
2456 page_info->page, in be_rx_compl_process_gro()
2457 page_info->page_offset, in be_rx_compl_process_gro()
2460 put_page(page_info->page); in be_rx_compl_process_gro()
2461 skb_frag_size_add(&skb_shinfo(skb)->frags[j], in be_rx_compl_process_gro()
2465 skb->truesize += rx_frag_size; in be_rx_compl_process_gro()
2466 remaining -= curr_frag_len; in be_rx_compl_process_gro()
2471 skb_shinfo(skb)->nr_frags = j + 1; in be_rx_compl_process_gro()
2472 skb->len = rxcp->pkt_size; in be_rx_compl_process_gro()
2473 skb->data_len = rxcp->pkt_size; in be_rx_compl_process_gro()
2474 skb->ip_summed = CHECKSUM_UNNECESSARY; in be_rx_compl_process_gro()
2475 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); in be_rx_compl_process_gro()
2476 if (adapter->netdev->features & NETIF_F_RXHASH) in be_rx_compl_process_gro()
2477 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3); in be_rx_compl_process_gro()
2479 skb->csum_level = rxcp->tunneled; in be_rx_compl_process_gro()
2481 if (rxcp->vlanf) in be_rx_compl_process_gro()
2482 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag); in be_rx_compl_process_gro()
2490 rxcp->pkt_size = GET_RX_COMPL_V1_BITS(pktsize, compl); in be_parse_rx_compl_v1()
2491 rxcp->vlanf = GET_RX_COMPL_V1_BITS(vtp, compl); in be_parse_rx_compl_v1()
2492 rxcp->err = GET_RX_COMPL_V1_BITS(err, compl); in be_parse_rx_compl_v1()
2493 rxcp->tcpf = GET_RX_COMPL_V1_BITS(tcpf, compl); in be_parse_rx_compl_v1()
2494 rxcp->udpf = GET_RX_COMPL_V1_BITS(udpf, compl); in be_parse_rx_compl_v1()
2495 rxcp->ip_csum = GET_RX_COMPL_V1_BITS(ipcksm, compl); in be_parse_rx_compl_v1()
2496 rxcp->l4_csum = GET_RX_COMPL_V1_BITS(l4_cksm, compl); in be_parse_rx_compl_v1()
2497 rxcp->ipv6 = GET_RX_COMPL_V1_BITS(ip_version, compl); in be_parse_rx_compl_v1()
2498 rxcp->num_rcvd = GET_RX_COMPL_V1_BITS(numfrags, compl); in be_parse_rx_compl_v1()
2499 rxcp->pkt_type = GET_RX_COMPL_V1_BITS(cast_enc, compl); in be_parse_rx_compl_v1()
2500 rxcp->rss_hash = GET_RX_COMPL_V1_BITS(rsshash, compl); in be_parse_rx_compl_v1()
2501 if (rxcp->vlanf) { in be_parse_rx_compl_v1()
2502 rxcp->qnq = GET_RX_COMPL_V1_BITS(qnq, compl); in be_parse_rx_compl_v1()
2503 rxcp->vlan_tag = GET_RX_COMPL_V1_BITS(vlan_tag, compl); in be_parse_rx_compl_v1()
2505 rxcp->port = GET_RX_COMPL_V1_BITS(port, compl); in be_parse_rx_compl_v1()
2506 rxcp->tunneled = in be_parse_rx_compl_v1()
2513 rxcp->pkt_size = GET_RX_COMPL_V0_BITS(pktsize, compl); in be_parse_rx_compl_v0()
2514 rxcp->vlanf = GET_RX_COMPL_V0_BITS(vtp, compl); in be_parse_rx_compl_v0()
2515 rxcp->err = GET_RX_COMPL_V0_BITS(err, compl); in be_parse_rx_compl_v0()
2516 rxcp->tcpf = GET_RX_COMPL_V0_BITS(tcpf, compl); in be_parse_rx_compl_v0()
2517 rxcp->udpf = GET_RX_COMPL_V0_BITS(udpf, compl); in be_parse_rx_compl_v0()
2518 rxcp->ip_csum = GET_RX_COMPL_V0_BITS(ipcksm, compl); in be_parse_rx_compl_v0()
2519 rxcp->l4_csum = GET_RX_COMPL_V0_BITS(l4_cksm, compl); in be_parse_rx_compl_v0()
2520 rxcp->ipv6 = GET_RX_COMPL_V0_BITS(ip_version, compl); in be_parse_rx_compl_v0()
2521 rxcp->num_rcvd = GET_RX_COMPL_V0_BITS(numfrags, compl); in be_parse_rx_compl_v0()
2522 rxcp->pkt_type = GET_RX_COMPL_V0_BITS(cast_enc, compl); in be_parse_rx_compl_v0()
2523 rxcp->rss_hash = GET_RX_COMPL_V0_BITS(rsshash, compl); in be_parse_rx_compl_v0()
2524 if (rxcp->vlanf) { in be_parse_rx_compl_v0()
2525 rxcp->qnq = GET_RX_COMPL_V0_BITS(qnq, compl); in be_parse_rx_compl_v0()
2526 rxcp->vlan_tag = GET_RX_COMPL_V0_BITS(vlan_tag, compl); in be_parse_rx_compl_v0()
2528 rxcp->port = GET_RX_COMPL_V0_BITS(port, compl); in be_parse_rx_compl_v0()
2529 rxcp->ip_frag = GET_RX_COMPL_V0_BITS(ip_frag, compl); in be_parse_rx_compl_v0()
2534 struct be_eth_rx_compl *compl = queue_tail_node(&rxo->cq); in be_rx_compl_get()
2535 struct be_rx_compl_info *rxcp = &rxo->rxcp; in be_rx_compl_get()
2536 struct be_adapter *adapter = rxo->adapter; in be_rx_compl_get()
2540 if (compl->dw[offsetof(struct amap_eth_rx_compl_v1, valid) / 32] == 0) in be_rx_compl_get()
2546 if (adapter->be3_native) in be_rx_compl_get()
2551 if (rxcp->ip_frag) in be_rx_compl_get()
2552 rxcp->l4_csum = 0; in be_rx_compl_get()
2554 if (rxcp->vlanf) { in be_rx_compl_get()
2556 * tagged only with the transparent outer vlan-tag and must in be_rx_compl_get()
2559 if (be_is_qnq_mode(adapter) && !rxcp->qnq) in be_rx_compl_get()
2560 rxcp->vlanf = 0; in be_rx_compl_get()
2563 rxcp->vlan_tag = swab16(rxcp->vlan_tag); in be_rx_compl_get()
2565 if (adapter->pvid == (rxcp->vlan_tag & VLAN_VID_MASK) && in be_rx_compl_get()
2566 !test_bit(rxcp->vlan_tag, adapter->vids)) in be_rx_compl_get()
2567 rxcp->vlanf = 0; in be_rx_compl_get()
2571 compl->dw[offsetof(struct amap_eth_rx_compl_v1, valid) / 32] = 0; in be_rx_compl_get()
2573 queue_tail_inc(&rxo->cq); in be_rx_compl_get()
2592 struct be_adapter *adapter = rxo->adapter; in be_post_rx_frags()
2594 struct be_queue_info *rxq = &rxo->q; in be_post_rx_frags()
2596 struct device *dev = &adapter->pdev->dev; in be_post_rx_frags()
2601 page_info = &rxo->page_info_tbl[rxq->head]; in be_post_rx_frags()
2602 for (posted = 0; posted < frags_needed && !page_info->page; posted++) { in be_post_rx_frags()
2604 pagep = be_alloc_pages(adapter->big_page_size, gfp); in be_post_rx_frags()
2606 rx_stats(rxo)->rx_post_fail++; in be_post_rx_frags()
2610 adapter->big_page_size, in be_post_rx_frags()
2615 adapter->drv_stats.dma_map_errors++; in be_post_rx_frags()
2623 page_info->page_offset = page_offset; in be_post_rx_frags()
2624 page_info->page = pagep; in be_post_rx_frags()
2627 frag_dmaaddr = page_dmaaddr + page_info->page_offset; in be_post_rx_frags()
2628 rxd->fragpa_lo = cpu_to_le32(frag_dmaaddr & 0xFFFFFFFF); in be_post_rx_frags()
2629 rxd->fragpa_hi = cpu_to_le32(upper_32_bits(frag_dmaaddr)); in be_post_rx_frags()
2633 adapter->big_page_size) { in be_post_rx_frags()
2635 page_info->last_frag = true; in be_post_rx_frags()
2643 page_info = &rxo->page_info_tbl[rxq->head]; in be_post_rx_frags()
2650 prev_page_info->last_frag = true; in be_post_rx_frags()
2655 atomic_add(posted, &rxq->used); in be_post_rx_frags()
2656 if (rxo->rx_post_starved) in be_post_rx_frags()
2657 rxo->rx_post_starved = false; in be_post_rx_frags()
2660 be_rxq_notify(adapter, rxq->id, notify); in be_post_rx_frags()
2661 posted -= notify; in be_post_rx_frags()
2663 } else if (atomic_read(&rxq->used) == 0) { in be_post_rx_frags()
2665 rxo->rx_post_starved = true; in be_post_rx_frags()
2673 tx_stats(txo)->tx_hdr_parse_err++; in be_update_tx_err()
2676 tx_stats(txo)->tx_dma_err++; in be_update_tx_err()
2679 tx_stats(txo)->tx_spoof_check_err++; in be_update_tx_err()
2688 tx_stats(txo)->tx_tso_err++; in lancer_update_tx_err()
2692 tx_stats(txo)->tx_spoof_check_err++; in lancer_update_tx_err()
2695 tx_stats(txo)->tx_qinq_err++; in lancer_update_tx_err()
2698 tx_stats(txo)->tx_internal_parity_err++; in lancer_update_tx_err()
2701 tx_stats(txo)->tx_dma_err++; in lancer_update_tx_err()
2704 tx_stats(txo)->tx_sge_err++; in lancer_update_tx_err()
2712 struct be_queue_info *tx_cq = &txo->cq; in be_tx_compl_get()
2713 struct be_tx_compl_info *txcp = &txo->txcp; in be_tx_compl_get()
2716 if (compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0) in be_tx_compl_get()
2723 txcp->status = GET_TX_COMPL_BITS(status, compl); in be_tx_compl_get()
2724 txcp->end_index = GET_TX_COMPL_BITS(wrb_index, compl); in be_tx_compl_get()
2726 if (txcp->status) { in be_tx_compl_get()
2728 lancer_update_tx_err(txo, txcp->status); in be_tx_compl_get()
2732 if (txcp->status == LANCER_TX_COMP_LSO_ERR || in be_tx_compl_get()
2733 txcp->status == LANCER_TX_COMP_PARITY_ERR || in be_tx_compl_get()
2734 txcp->status == LANCER_TX_COMP_SGE_ERR) in be_tx_compl_get()
2737 be_update_tx_err(txo, txcp->status); in be_tx_compl_get()
2744 compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0; in be_tx_compl_get()
2752 struct sk_buff **sent_skbs = txo->sent_skb_list; in be_tx_compl_process()
2753 struct be_queue_info *txq = &txo->q; in be_tx_compl_process()
2761 if (sent_skbs[txq->tail]) { in be_tx_compl_process()
2765 skb = sent_skbs[txq->tail]; in be_tx_compl_process()
2766 sent_skbs[txq->tail] = NULL; in be_tx_compl_process()
2772 frag_index = txq->tail; in be_tx_compl_process()
2773 unmap_tx_frag(&adapter->pdev->dev, wrb, in be_tx_compl_process()
2791 eqe = queue_tail_node(&eqo->q); in events_get()
2792 if (eqe->evt == 0) in events_get()
2796 eqe->evt = 0; in events_get()
2798 queue_tail_inc(&eqo->q); in events_get()
2809 be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0); in be_eq_clean()
2815 struct be_queue_info *rxq = &rxo->q; in be_rxq_clean()
2818 while (atomic_read(&rxq->used) > 0) { in be_rxq_clean()
2820 put_page(page_info->page); in be_rxq_clean()
2823 BUG_ON(atomic_read(&rxq->used)); in be_rxq_clean()
2824 rxq->tail = 0; in be_rxq_clean()
2825 rxq->head = 0; in be_rxq_clean()
2830 struct be_queue_info *rx_cq = &rxo->cq; in be_rx_cq_clean()
2832 struct be_adapter *adapter = rxo->adapter; in be_rx_cq_clean()
2850 dev_warn(&adapter->pdev->dev, in be_rx_cq_clean()
2854 be_cq_notify(adapter, rx_cq->id, true, 0); in be_rx_cq_clean()
2858 be_cq_notify(adapter, rx_cq->id, false, 1); in be_rx_cq_clean()
2859 if (rxcp->num_rcvd == 0) in be_rx_cq_clean()
2865 be_cq_notify(adapter, rx_cq->id, false, 0); in be_rx_cq_clean()
2870 struct device *dev = &adapter->pdev->dev; in be_tx_compl_clean()
2880 pending_txqs = adapter->num_tx_qs; in be_tx_compl_clean()
2885 txq = &txo->q; in be_tx_compl_clean()
2889 txcp->end_index); in be_tx_compl_clean()
2893 be_cq_notify(adapter, txo->cq.id, false, cmpl); in be_tx_compl_clean()
2894 atomic_sub(num_wrbs, &txq->used); in be_tx_compl_clean()
2898 pending_txqs--; in be_tx_compl_clean()
2910 txq = &txo->q; in be_tx_compl_clean()
2912 if (atomic_read(&txq->used)) { in be_tx_compl_clean()
2913 dev_info(dev, "txq%d: cleaning %d pending tx-wrbs\n", in be_tx_compl_clean()
2914 i, atomic_read(&txq->used)); in be_tx_compl_clean()
2915 notified_idx = txq->tail; in be_tx_compl_clean()
2916 end_idx = txq->tail; in be_tx_compl_clean()
2917 index_adv(&end_idx, atomic_read(&txq->used) - 1, in be_tx_compl_clean()
2918 txq->len); in be_tx_compl_clean()
2919 /* Use the tx-compl process logic to handle requests in be_tx_compl_clean()
2923 atomic_sub(num_wrbs, &txq->used); in be_tx_compl_clean()
2924 BUG_ON(atomic_read(&txq->used)); in be_tx_compl_clean()
2925 txo->pend_wrb_cnt = 0; in be_tx_compl_clean()
2929 txq->head = notified_idx; in be_tx_compl_clean()
2930 txq->tail = notified_idx; in be_tx_compl_clean()
2941 if (eqo->q.created) { in be_evt_queues_destroy()
2943 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); in be_evt_queues_destroy()
2944 netif_napi_del(&eqo->napi); in be_evt_queues_destroy()
2945 free_cpumask_var(eqo->affinity_mask); in be_evt_queues_destroy()
2947 be_queue_free(adapter, &eqo->q); in be_evt_queues_destroy()
2959 adapter->num_evt_qs = min_t(u16, num_irqs(adapter), in be_evt_queues_create()
2960 max(adapter->cfg_num_rx_irqs, in be_evt_queues_create()
2961 adapter->cfg_num_tx_irqs)); in be_evt_queues_create()
2963 adapter->aic_enabled = true; in be_evt_queues_create()
2966 int numa_node = dev_to_node(&adapter->pdev->dev); in be_evt_queues_create()
2968 aic = &adapter->aic_obj[i]; in be_evt_queues_create()
2969 eqo->adapter = adapter; in be_evt_queues_create()
2970 eqo->idx = i; in be_evt_queues_create()
2971 aic->max_eqd = BE_MAX_EQD; in be_evt_queues_create()
2973 eq = &eqo->q; in be_evt_queues_create()
2983 if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) in be_evt_queues_create()
2984 return -ENOMEM; in be_evt_queues_create()
2986 eqo->affinity_mask); in be_evt_queues_create()
2987 netif_napi_add(adapter->netdev, &eqo->napi, be_poll); in be_evt_queues_create()
2996 q = &adapter->mcc_obj.q; in be_mcc_queues_destroy()
2997 if (q->created) in be_mcc_queues_destroy()
3001 q = &adapter->mcc_obj.cq; in be_mcc_queues_destroy()
3002 if (q->created) in be_mcc_queues_destroy()
3012 cq = &adapter->mcc_obj.cq; in be_mcc_queues_create()
3018 if (be_cmd_cq_create(adapter, cq, &mcc_eqo(adapter)->q, true, 0)) in be_mcc_queues_create()
3021 q = &adapter->mcc_obj.q; in be_mcc_queues_create()
3037 return -1; in be_mcc_queues_create()
3047 q = &txo->q; in be_tx_queues_destroy()
3048 if (q->created) in be_tx_queues_destroy()
3052 q = &txo->cq; in be_tx_queues_destroy()
3053 if (q->created) in be_tx_queues_destroy()
3066 adapter->num_tx_qs = min(adapter->num_evt_qs, adapter->cfg_num_tx_irqs); in be_tx_qs_create()
3069 cq = &txo->cq; in be_tx_qs_create()
3075 u64_stats_init(&txo->stats.sync); in be_tx_qs_create()
3076 u64_stats_init(&txo->stats.sync_compl); in be_tx_qs_create()
3081 eqo = &adapter->eq_obj[i % adapter->num_evt_qs]; in be_tx_qs_create()
3082 status = be_cmd_cq_create(adapter, cq, &eqo->q, false, 3); in be_tx_qs_create()
3086 status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN, in be_tx_qs_create()
3095 netif_set_xps_queue(adapter->netdev, eqo->affinity_mask, in be_tx_qs_create()
3096 eqo->idx); in be_tx_qs_create()
3099 dev_info(&adapter->pdev->dev, "created %d TX queue(s)\n", in be_tx_qs_create()
3100 adapter->num_tx_qs); in be_tx_qs_create()
3111 q = &rxo->cq; in be_rx_cqs_destroy()
3112 if (q->created) in be_rx_cqs_destroy()
3124 adapter->num_rss_qs = in be_rx_cqs_create()
3125 min(adapter->num_evt_qs, adapter->cfg_num_rx_irqs); in be_rx_cqs_create()
3128 if (adapter->num_rss_qs < 2) in be_rx_cqs_create()
3129 adapter->num_rss_qs = 0; in be_rx_cqs_create()
3131 adapter->num_rx_qs = adapter->num_rss_qs + adapter->need_def_rxq; in be_rx_cqs_create()
3136 if (adapter->num_rx_qs == 0) in be_rx_cqs_create()
3137 adapter->num_rx_qs = 1; in be_rx_cqs_create()
3139 adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; in be_rx_cqs_create()
3141 rxo->adapter = adapter; in be_rx_cqs_create()
3142 cq = &rxo->cq; in be_rx_cqs_create()
3148 u64_stats_init(&rxo->stats.sync); in be_rx_cqs_create()
3149 eq = &adapter->eq_obj[i % adapter->num_evt_qs].q; in be_rx_cqs_create()
3155 dev_info(&adapter->pdev->dev, in be_rx_cqs_create()
3156 "created %d RX queue(s)\n", adapter->num_rx_qs); in be_rx_cqs_create()
3163 struct be_adapter *adapter = eqo->adapter; in be_intx()
3169 * a while to de-assert INTx or in BE2 where occasionaly in be_intx()
3174 if (napi_schedule_prep(&eqo->napi)) { in be_intx()
3176 __napi_schedule(&eqo->napi); in be_intx()
3178 eqo->spurious_intr = 0; in be_intx()
3180 be_eq_notify(adapter, eqo->q.id, false, true, num_evts, 0); in be_intx()
3186 if (num_evts || eqo->spurious_intr++ == 0) in be_intx()
3196 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_msix()
3197 napi_schedule(&eqo->napi); in be_msix()
3203 return (rxcp->tcpf && !rxcp->err && rxcp->l4_csum) ? true : false; in do_gro()
3209 struct be_adapter *adapter = rxo->adapter; in be_process_rx()
3210 struct be_queue_info *rx_cq = &rxo->cq; in be_process_rx()
3221 if (unlikely(rxcp->num_rcvd == 0)) in be_process_rx()
3225 if (unlikely(!rxcp->pkt_size)) { in be_process_rx()
3233 if (unlikely(rxcp->port != adapter->port_num && in be_process_rx()
3245 frags_consumed += rxcp->num_rcvd; in be_process_rx()
3250 be_cq_notify(adapter, rx_cq->id, true, work_done); in be_process_rx()
3252 /* When an rx-obj gets into post_starved state, just in be_process_rx()
3255 if (atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM && in be_process_rx()
3256 !rxo->rx_post_starved) in be_process_rx()
3273 num_wrbs += be_tx_compl_process(adapter, txo, txcp->end_index); in be_process_tx()
3278 be_cq_notify(adapter, txo->cq.id, true, work_done); in be_process_tx()
3279 atomic_sub(num_wrbs, &txo->q.used); in be_process_tx()
3283 if (__netif_subqueue_stopped(adapter->netdev, idx) && in be_process_tx()
3285 netif_wake_subqueue(adapter->netdev, idx); in be_process_tx()
3288 u64_stats_update_begin(&tx_stats(txo)->sync_compl); in be_process_tx()
3289 tx_stats(txo)->tx_compl += work_done; in be_process_tx()
3290 u64_stats_update_end(&tx_stats(txo)->sync_compl); in be_process_tx()
3297 struct be_adapter *adapter = eqo->adapter; in be_poll()
3329 be_eq_notify(adapter, eqo->q.id, true, false, num_evts, in be_poll()
3333 be_eq_notify(adapter, eqo->q.id, false, false, num_evts, 0); in be_poll()
3342 struct device *dev = &adapter->pdev->dev; in be_detect_error()
3350 sliport_status = ioread32(adapter->db + SLIPORT_STATUS_OFFSET); in be_detect_error()
3353 sliport_err1 = ioread32(adapter->db + in be_detect_error()
3355 sliport_err2 = ioread32(adapter->db + in be_detect_error()
3372 ue_lo = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_LOW); in be_detect_error()
3373 ue_hi = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_HIGH); in be_detect_error()
3374 ue_lo_mask = ioread32(adapter->pcicfg + in be_detect_error()
3376 ue_hi_mask = ioread32(adapter->pcicfg + in be_detect_error()
3421 pci_disable_msix(adapter->pdev); in be_msix_disable()
3422 adapter->num_msix_vec = 0; in be_msix_disable()
3423 adapter->num_msix_roce_vec = 0; in be_msix_disable()
3430 struct device *dev = &adapter->pdev->dev; in be_msix_enable()
3439 be_max_func_eqs(adapter) - be_max_nic_eqs(adapter); in be_msix_enable()
3443 num_vec = max(adapter->cfg_num_rx_irqs, in be_msix_enable()
3444 adapter->cfg_num_tx_irqs); in be_msix_enable()
3448 adapter->msix_entries[i].entry = i; in be_msix_enable()
3450 num_vec = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, in be_msix_enable()
3456 adapter->num_msix_roce_vec = num_vec / 2; in be_msix_enable()
3457 dev_info(dev, "enabled %d MSI-x vector(s) for RoCE\n", in be_msix_enable()
3458 adapter->num_msix_roce_vec); in be_msix_enable()
3461 adapter->num_msix_vec = num_vec - adapter->num_msix_roce_vec; in be_msix_enable()
3463 dev_info(dev, "enabled %d MSI-x vector(s) for NIC\n", in be_msix_enable()
3464 adapter->num_msix_vec); in be_msix_enable()
3479 return adapter->msix_entries[eqo->msix_idx].vector; in be_msix_vec_get()
3484 struct net_device *netdev = adapter->netdev; in be_msix_register()
3489 sprintf(eqo->desc, "%s-q%d", netdev->name, i); in be_msix_register()
3491 status = request_irq(vec, be_msix, 0, eqo->desc, eqo); in be_msix_register()
3495 irq_update_affinity_hint(vec, eqo->affinity_mask); in be_msix_register()
3500 for (i--; i >= 0; i--) { in be_msix_register()
3501 eqo = &adapter->eq_obj[i]; in be_msix_register()
3504 dev_warn(&adapter->pdev->dev, "MSIX Request IRQ failed - err %d\n", in be_msix_register()
3512 struct net_device *netdev = adapter->netdev; in be_irq_register()
3525 netdev->irq = adapter->pdev->irq; in be_irq_register()
3526 status = request_irq(netdev->irq, be_intx, IRQF_SHARED, netdev->name, in be_irq_register()
3527 &adapter->eq_obj[0]); in be_irq_register()
3529 dev_err(&adapter->pdev->dev, in be_irq_register()
3530 "INTx request IRQ failed - err %d\n", status); in be_irq_register()
3534 adapter->isr_registered = true; in be_irq_register()
3540 struct net_device *netdev = adapter->netdev; in be_irq_unregister()
3544 if (!adapter->isr_registered) in be_irq_unregister()
3549 free_irq(netdev->irq, &adapter->eq_obj[0]); in be_irq_unregister()
3561 adapter->isr_registered = false; in be_irq_unregister()
3566 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_destroy()
3572 q = &rxo->q; in be_rx_qs_destroy()
3573 if (q->created) { in be_rx_qs_destroy()
3582 if (atomic_read(&q->used) == 0) in be_rx_qs_destroy()
3594 if (rss->rss_flags) { in be_rx_qs_destroy()
3595 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_destroy()
3596 be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_destroy()
3597 128, rss->rss_hkey); in be_rx_qs_destroy()
3606 be_dev_mac_del(adapter, adapter->pmac_id[0]); in be_disable_if_filters()
3607 eth_zero_addr(adapter->dev_mac); in be_disable_if_filters()
3616 * - VF's IFACE flags get cleared in the detach path in be_disable_if_filters()
3617 * - IFACE create is issued by the VF in the attach path in be_disable_if_filters()
3618 * Due to a bug in the BE3/Skyhawk-R FW in be_disable_if_filters()
3625 * To avoid this, disable RX-filter flags only for Lancer. in be_disable_if_filters()
3629 adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS; in be_disable_if_filters()
3642 if (!(adapter->flags & BE_FLAGS_SETUP_DONE)) in be_close()
3652 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { in be_close()
3654 napi_disable(&eqo->napi); in be_close()
3656 adapter->flags &= ~BE_FLAGS_NAPI_ENABLED; in be_close()
3673 synchronize_irq(netdev->irq); in be_close()
3684 struct rss_info *rss = &adapter->rss_info; in be_rx_qs_create()
3690 rc = be_queue_alloc(adapter, &rxo->q, RX_Q_LEN, in be_rx_qs_create()
3696 if (adapter->need_def_rxq || !adapter->num_rss_qs) { in be_rx_qs_create()
3698 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3699 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3700 false, &rxo->rss_id); in be_rx_qs_create()
3706 rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, in be_rx_qs_create()
3707 rx_frag_size, adapter->if_handle, in be_rx_qs_create()
3708 true, &rxo->rss_id); in be_rx_qs_create()
3714 for (j = 0; j < RSS_INDIR_TABLE_LEN; j += adapter->num_rss_qs) { in be_rx_qs_create()
3718 rss->rsstable[j + i] = rxo->rss_id; in be_rx_qs_create()
3719 rss->rss_queue[j + i] = i; in be_rx_qs_create()
3722 rss->rss_flags = RSS_ENABLE_TCP_IPV4 | RSS_ENABLE_IPV4 | in be_rx_qs_create()
3726 rss->rss_flags |= RSS_ENABLE_UDP_IPV4 | in be_rx_qs_create()
3730 rc = be_cmd_rss_config(adapter, rss->rsstable, rss->rss_flags, in be_rx_qs_create()
3733 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_create()
3737 memcpy(rss->rss_hkey, rss_key, RSS_HASH_KEY_LEN); in be_rx_qs_create()
3740 rss->rss_flags = RSS_ENABLE_NONE; in be_rx_qs_create()
3744 /* Post 1 less than RXQ-len to avoid head being equal to tail, in be_rx_qs_create()
3748 be_post_rx_frags(rxo, GFP_KERNEL, RX_Q_LEN - 1); in be_rx_qs_create()
3761 /* Normally this condition usually true as the ->dev_mac is zeroed. in be_enable_if_filters()
3762 * But on BE3 VFs the initial MAC is pre-programmed by PF and in be_enable_if_filters()
3765 if (!ether_addr_equal(adapter->dev_mac, adapter->netdev->dev_addr)) { in be_enable_if_filters()
3766 int old_pmac_id = -1; in be_enable_if_filters()
3768 /* Remember old programmed MAC if any - can happen on BE3 VF */ in be_enable_if_filters()
3769 if (!is_zero_ether_addr(adapter->dev_mac)) in be_enable_if_filters()
3770 old_pmac_id = adapter->pmac_id[0]; in be_enable_if_filters()
3772 status = be_dev_mac_add(adapter, adapter->netdev->dev_addr); in be_enable_if_filters()
3779 if (old_pmac_id >= 0 && old_pmac_id != adapter->pmac_id[0]) in be_enable_if_filters()
3782 ether_addr_copy(adapter->dev_mac, adapter->netdev->dev_addr); in be_enable_if_filters()
3785 if (adapter->vlans_added) in be_enable_if_filters()
3815 be_cq_notify(adapter, rxo->cq.id, true, 0); in be_open()
3818 be_cq_notify(adapter, txo->cq.id, true, 0); in be_open()
3823 napi_enable(&eqo->napi); in be_open()
3824 be_eq_notify(adapter, eqo->q.id, true, true, 0, 0); in be_open()
3826 adapter->flags |= BE_FLAGS_NAPI_ENABLED; in be_open()
3838 be_close(adapter->netdev); in be_open()
3839 return -EIO; in be_open()
3846 addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0); in be_vf_eth_addr_generate()
3852 memcpy(mac, adapter->netdev->dev_addr, 3); in be_vf_eth_addr_generate()
3873 vf_cfg->if_handle, in be_vf_eth_addr_config()
3874 &vf_cfg->pmac_id, vf + 1); in be_vf_eth_addr_config()
3876 status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle, in be_vf_eth_addr_config()
3880 dev_err(&adapter->pdev->dev, in be_vf_eth_addr_config()
3884 memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); in be_vf_eth_addr_config()
3898 status = be_cmd_get_active_mac(adapter, vf_cfg->pmac_id, in be_vfs_mac_query()
3899 mac, vf_cfg->if_handle, in be_vfs_mac_query()
3903 memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); in be_vfs_mac_query()
3913 if (pci_vfs_assigned(adapter->pdev)) { in be_vf_clear()
3914 dev_warn(&adapter->pdev->dev, in be_vf_clear()
3919 pci_disable_sriov(adapter->pdev); in be_vf_clear()
3923 be_cmd_pmac_del(adapter, vf_cfg->if_handle, in be_vf_clear()
3924 vf_cfg->pmac_id, vf + 1); in be_vf_clear()
3926 be_cmd_set_mac(adapter, NULL, vf_cfg->if_handle, in be_vf_clear()
3929 be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1); in be_vf_clear()
3934 adapter->if_handle, in be_vf_clear()
3937 kfree(adapter->vf_cfg); in be_vf_clear()
3938 adapter->num_vfs = 0; in be_vf_clear()
3939 adapter->flags &= ~BE_FLAGS_SRIOV_ENABLED; in be_vf_clear()
3952 if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) { in be_cancel_worker()
3953 cancel_delayed_work_sync(&adapter->work); in be_cancel_worker()
3954 adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED; in be_cancel_worker()
3960 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_cancel_err_detection()
3965 if (adapter->flags & BE_FLAGS_ERR_DETECTION_SCHEDULED) { in be_cancel_err_detection()
3966 cancel_delayed_work_sync(&err_rec->err_detection_work); in be_cancel_err_detection()
3967 adapter->flags &= ~BE_FLAGS_ERR_DETECTION_SCHEDULED; in be_cancel_err_detection()
3985 struct device *dev = &adapter->pdev->dev; in be_vxlan_set_port()
3988 status = be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_set_port()
3994 adapter->flags |= BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_set_port()
3996 status = be_cmd_set_vxlan_port(adapter, ti->port); in be_vxlan_set_port()
4001 adapter->vxlan_port = ti->port; in be_vxlan_set_port()
4003 netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | in be_vxlan_set_port()
4008 be16_to_cpu(ti->port)); in be_vxlan_set_port()
4017 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) in be_vxlan_unset_port()
4018 be_cmd_manage_iface(adapter, adapter->if_handle, in be_vxlan_unset_port()
4021 if (adapter->vxlan_port) in be_vxlan_unset_port()
4024 adapter->flags &= ~BE_FLAGS_VXLAN_OFFLOADS; in be_vxlan_unset_port()
4025 adapter->vxlan_port = 0; in be_vxlan_unset_port()
4027 netdev->hw_enc_features = 0; in be_vxlan_unset_port()
4044 struct be_resources res = adapter->pool_res; in be_calculate_vf_res()
4052 * at VF-EQ-count. Any remainder queues belong to the PF. in be_calculate_vf_res()
4057 /* Skyhawk-R chip supports only MAX_PORT_RSS_TABLES in be_calculate_vf_res()
4077 vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT); in be_calculate_vf_res()
4091 vft_res->flags |= BIT(IF_CAPS_FLAGS_VALID_SHIFT); in be_calculate_vf_res()
4095 vft_res->vf_if_cap_flags = vf_if_cap_flags; in be_calculate_vf_res()
4096 vft_res->max_rx_qs = num_vf_qs; in be_calculate_vf_res()
4097 vft_res->max_rss_qs = num_vf_qs; in be_calculate_vf_res()
4098 vft_res->max_tx_qs = res.max_tx_qs / (num_vfs + 1); in be_calculate_vf_res()
4099 vft_res->max_cq_count = res.max_cq_count / (num_vfs + 1); in be_calculate_vf_res()
4105 vft_res->max_uc_mac = res.max_uc_mac / (num_vfs + 1); in be_calculate_vf_res()
4108 vft_res->max_vlans = res.max_vlans / (num_vfs + 1); in be_calculate_vf_res()
4111 vft_res->max_iface_count = res.max_iface_count / (num_vfs + 1); in be_calculate_vf_res()
4114 vft_res->max_mcc_count = res.max_mcc_count / (num_vfs + 1); in be_calculate_vf_res()
4119 be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_if_destroy()
4121 kfree(adapter->pmac_id); in be_if_destroy()
4122 adapter->pmac_id = NULL; in be_if_destroy()
4124 kfree(adapter->mc_list); in be_if_destroy()
4125 adapter->mc_list = NULL; in be_if_destroy()
4127 kfree(adapter->uc_list); in be_if_destroy()
4128 adapter->uc_list = NULL; in be_if_destroy()
4133 struct pci_dev *pdev = adapter->pdev; in be_clear()
4143 /* Re-configure FW to distribute resources evenly across max-supported in be_clear()
4151 be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_clear()
4156 be_vxlan_unset_port(adapter->netdev, 0, 0, NULL); in be_clear()
4163 adapter->flags &= ~BE_FLAGS_SETUP_DONE; in be_clear()
4195 &vf_cfg->if_handle, vf + 1); in be_vfs_if_create()
4208 adapter->vf_cfg = kcalloc(adapter->num_vfs, sizeof(*vf_cfg), in be_vf_setup_init()
4210 if (!adapter->vf_cfg) in be_vf_setup_init()
4211 return -ENOMEM; in be_vf_setup_init()
4214 vf_cfg->if_handle = -1; in be_vf_setup_init()
4215 vf_cfg->pmac_id = -1; in be_vf_setup_init()
4222 struct device *dev = &adapter->pdev->dev; in be_vf_setup()
4227 old_vfs = pci_num_vf(adapter->pdev); in be_vf_setup()
4255 status = be_cmd_get_fn_privileges(adapter, &vf_cfg->privileges, in be_vf_setup()
4257 if (!status && !(vf_cfg->privileges & BE_PRIV_FILTMGMT)) { in be_vf_setup()
4259 vf_cfg->privileges | in be_vf_setup()
4263 vf_cfg->privileges |= BE_PRIV_FILTMGMT; in be_vf_setup()
4274 vf_cfg->if_handle, NULL, in be_vf_setup()
4277 vf_cfg->spoofchk = spoofchk; in be_vf_setup()
4288 status = pci_enable_sriov(adapter->pdev, adapter->num_vfs); in be_vf_setup()
4291 adapter->num_vfs = 0; in be_vf_setup()
4299 adapter->if_handle, in be_vf_setup()
4305 adapter->flags |= BE_FLAGS_SRIOV_ENABLED; in be_vf_setup()
4333 bool use_sriov = adapter->num_vfs ? 1 : 0; in BEx_get_resources()
4336 res->max_uc_mac = BE_UC_PMAC_COUNT; in BEx_get_resources()
4338 res->max_uc_mac = BE_VF_UC_PMAC_COUNT; in BEx_get_resources()
4340 adapter->mc_type = be_convert_mc_type(adapter->function_mode); in BEx_get_resources()
4344 * when multi-channel is enabled in BEx_get_resources()
4347 res->max_vlans = BE_NUM_VLANS_SUPPORTED/8; in BEx_get_resources()
4349 /* In a non-qnq multichannel mode, the pvid in BEx_get_resources()
4352 res->max_vlans = (BE_NUM_VLANS_SUPPORTED / 4) - 1; in BEx_get_resources()
4354 res->max_vlans = BE_NUM_VLANS_SUPPORTED; in BEx_get_resources()
4357 res->max_mcast_mac = BE_MAX_MC; in BEx_get_resources()
4360 * 2) Create multiple TX rings on a BE3-R multi-channel interface in BEx_get_resources()
4361 * *only* if it is RSS-capable. in BEx_get_resources()
4363 if (BE2_chip(adapter) || use_sriov || (adapter->port_num > 1) || in BEx_get_resources()
4366 !(adapter->function_caps & BE_FUNCTION_CAPS_RSS))) { in BEx_get_resources()
4367 res->max_tx_qs = 1; in BEx_get_resources()
4368 } else if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) { in BEx_get_resources()
4372 * GET_PROFILE_CONFIG cmd to query the per-function TXQ limits in BEx_get_resources()
4378 res->max_tx_qs = super_nic_res.max_tx_qs ? : BE3_MAX_TX_QS; in BEx_get_resources()
4380 res->max_tx_qs = BE3_MAX_TX_QS; in BEx_get_resources()
4383 if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && in BEx_get_resources()
4385 res->max_rss_qs = (adapter->be3_native) ? in BEx_get_resources()
4387 res->max_rx_qs = res->max_rss_qs + 1; in BEx_get_resources()
4390 res->max_evt_qs = (be_max_vfs(adapter) > 0) ? in BEx_get_resources()
4393 res->max_evt_qs = 1; in BEx_get_resources()
4395 res->if_cap_flags = BE_IF_CAP_FLAGS_WANT; in BEx_get_resources()
4396 res->if_cap_flags &= ~BE_IF_FLAGS_DEFQ_RSS; in BEx_get_resources()
4397 if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS)) in BEx_get_resources()
4398 res->if_cap_flags &= ~BE_IF_FLAGS_RSS; in BEx_get_resources()
4403 adapter->vlan_prio_bmap = 0xff; in be_setup_init()
4404 adapter->phy.link_speed = -1; in be_setup_init()
4405 adapter->if_handle = -1; in be_setup_init()
4406 adapter->be3_native = false; in be_setup_init()
4407 adapter->if_flags = 0; in be_setup_init()
4408 adapter->phy_state = BE_UNKNOWN_PHY_STATE; in be_setup_init()
4410 adapter->cmd_privileges = MAX_PRIVILEGES; in be_setup_init()
4412 adapter->cmd_privileges = MIN_PRIVILEGES; in be_setup_init()
4417 * As a result, in the case of SRIOV and in particular multi-partition configs
4418 * the driver needs to calcuate a proportional share of RSS Tables per PF-pool
4419 * for distribution between the VFs. This self-imposed limit will determine the
4431 rss_tables_on_port = MAX_PORT_RSS_TABLES - port_res.nic_pfs; in be_calculate_pf_pool_rss_tables()
4436 adapter->pool_res.max_rss_tables = in be_calculate_pf_pool_rss_tables()
4450 max_vfs = pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4454 adapter->pool_res = res; in be_get_sriov_config()
4458 * Instead use the TotalVFs value stored in the pci-dev struct. in be_get_sriov_config()
4460 old_vfs = pci_num_vf(adapter->pdev); in be_get_sriov_config()
4462 dev_info(&adapter->pdev->dev, "%d VFs are already enabled\n", in be_get_sriov_config()
4465 adapter->pool_res.max_vfs = in be_get_sriov_config()
4466 pci_sriov_get_totalvfs(adapter->pdev); in be_get_sriov_config()
4467 adapter->num_vfs = old_vfs; in be_get_sriov_config()
4472 dev_info(&adapter->pdev->dev, in be_get_sriov_config()
4481 int old_vfs = pci_num_vf(adapter->pdev); in be_alloc_sriov_res()
4488 pci_sriov_set_totalvfs(adapter->pdev, be_max_vfs(adapter)); in be_alloc_sriov_res()
4490 /* When the HW is in SRIOV capable configuration, the PF-pool in be_alloc_sriov_res()
4497 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, 0, in be_alloc_sriov_res()
4500 dev_err(&adapter->pdev->dev, in be_alloc_sriov_res()
4507 struct device *dev = &adapter->pdev->dev; in be_get_resources()
4511 /* For Lancer, SH etc read per-function resource limits from FW. in be_get_resources()
4513 * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits in be_get_resources()
4525 res.max_rss_qs -= 1; in be_get_resources()
4531 adapter->res = res; in be_get_resources()
4533 /* If FW supports RSS default queue, then skip creating non-RSS in be_get_resources()
4534 * queue for non-IP traffic. in be_get_resources()
4536 adapter->need_def_rxq = (be_if_cap_flags(adapter) & in be_get_resources()
4543 dev_info(dev, "Max: uc-macs %d, mc-macs %d, vlans %d\n", in be_get_resources()
4548 adapter->cfg_num_rx_irqs = in be_get_resources()
4551 adapter->cfg_num_tx_irqs = adapter->cfg_num_rx_irqs; in be_get_resources()
4569 be_cmd_get_fat_dump_len(adapter, &adapter->fat_dump_len); in be_get_config()
4573 adapter->msg_enable = in be_get_config()
4578 pci_enable_wake(adapter->pdev, PCI_D3hot, adapter->wol_en); in be_get_config()
4579 pci_enable_wake(adapter->pdev, PCI_D3cold, adapter->wol_en); in be_get_config()
4586 dev_info(&adapter->pdev->dev, in be_get_config()
4598 if (is_zero_ether_addr(adapter->netdev->dev_addr)) { in be_mac_setup()
4603 eth_hw_addr_set(adapter->netdev, mac); in be_mac_setup()
4604 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); in be_mac_setup()
4608 memcpy(adapter->dev_mac, mac, ETH_ALEN); in be_mac_setup()
4616 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_schedule_worker()
4617 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()
4682 adapter->pmac_id = kcalloc(be_max_uc(adapter), in be_if_create()
4683 sizeof(*adapter->pmac_id), GFP_KERNEL); in be_if_create()
4684 if (!adapter->pmac_id) in be_if_create()
4685 return -ENOMEM; in be_if_create()
4687 adapter->mc_list = kcalloc(be_max_mc(adapter), in be_if_create()
4688 sizeof(*adapter->mc_list), GFP_KERNEL); in be_if_create()
4689 if (!adapter->mc_list) in be_if_create()
4690 return -ENOMEM; in be_if_create()
4692 adapter->uc_list = kcalloc(be_max_uc(adapter), in be_if_create()
4693 sizeof(*adapter->uc_list), GFP_KERNEL); in be_if_create()
4694 if (!adapter->uc_list) in be_if_create()
4695 return -ENOMEM; in be_if_create()
4697 if (adapter->cfg_num_rx_irqs == 1) in be_if_create()
4703 &adapter->if_handle, 0); in be_if_create()
4708 struct net_device *netdev = adapter->netdev; in be_update_queues()
4713 * function, synchronize with an already-running dev_watchdog in be_update_queues()
4725 /* If any vectors have been shared with RoCE we cannot re-program in be_update_queues()
4728 if (!adapter->num_msix_roce_vec) in be_update_queues()
4732 status = be_cmd_if_destroy(adapter, adapter->if_handle, 0); in be_update_queues()
4752 /* The IF was destroyed and re-created. We need to clear in be_update_queues()
4758 adapter->if_flags &= ~BE_IF_FLAGS_ALL_PROMISCUOUS; in be_update_queues()
4785 return pci_num_vf(adapter->pdev) == 0; in be_reset_required()
4822 struct device *dev = &adapter->pdev->dev; in be_setup()
4870 be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0); in be_setup()
4877 dev_info(dev, "FW version is %s\n", adapter->fw_ver); in be_setup()
4879 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) { in be_setup()
4881 adapter->fw_ver); in be_setup()
4885 status = be_cmd_set_flow_control(adapter, adapter->tx_fc, in be_setup()
4886 adapter->rx_fc); in be_setup()
4888 be_cmd_get_flow_control(adapter, &adapter->tx_fc, in be_setup()
4889 &adapter->rx_fc); in be_setup()
4891 dev_info(&adapter->pdev->dev, "HW Flow control - TX:%d RX:%d\n", in be_setup()
4892 adapter->tx_fc, adapter->rx_fc); in be_setup()
4904 be_cmd_set_hsw_config(adapter, 0, 0, adapter->if_handle, in be_setup()
4907 if (adapter->num_vfs) in be_setup()
4912 adapter->phy.fc_autoneg = 1; in be_setup()
4918 adapter->flags |= BE_FLAGS_SETUP_DONE; in be_setup()
4933 be_eq_notify(eqo->adapter, eqo->q.id, false, true, 0, 0); in be_netpoll()
4934 napi_schedule(&eqo->napi); in be_netpoll()
4944 if (!netif_running(adapter->netdev)) { in be_load_fw()
4945 dev_err(&adapter->pdev->dev, in be_load_fw()
4947 return -ENETDOWN; in be_load_fw()
4950 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); in be_load_fw()
4954 dev_info(&adapter->pdev->dev, "Flashing firmware file %s\n", fw_file); in be_load_fw()
4979 return -EOPNOTSUPP; in be_ndo_bridge_setlink()
4983 return -EINVAL; in be_ndo_bridge_setlink()
4991 return -EOPNOTSUPP; in be_ndo_bridge_setlink()
4994 return -EINVAL; in be_ndo_bridge_setlink()
4997 adapter->if_handle, in be_ndo_bridge_setlink()
5004 dev_info(&adapter->pdev->dev, "enabled switch mode: %s\n", in be_ndo_bridge_setlink()
5010 dev_err(&adapter->pdev->dev, "Failed to set switch mode %s\n", in be_ndo_bridge_setlink()
5026 /* VEB is disabled in non-SR-IOV profiles on BE3/Lancer */ in be_ndo_bridge_getlink()
5027 if (!pci_sriov_get_totalvfs(adapter->pdev)) in be_ndo_bridge_getlink()
5032 adapter->if_handle, &hsw_mode, in be_ndo_bridge_getlink()
5054 dev_err(&adapter->pdev->dev, in be_alloc_work()
5059 INIT_WORK(&work->work, func); in be_alloc_work()
5060 work->adapter = adapter; in be_alloc_work()
5083 (skb_shinfo(skb)->gso_size < 256 || in be_features_check()
5084 skb_shinfo(skb)->gso_segs == 1)) in be_features_check()
5089 * Q-in-Q packets. in be_features_check()
5093 if (!skb->encapsulation || in be_features_check()
5094 !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)) in be_features_check()
5101 * offloads are configured in Skyhawk-R. in be_features_check()
5105 l4_hdr = ip_hdr(skb)->protocol; in be_features_check()
5108 l4_hdr = ipv6_hdr(skb)->nexthdr; in be_features_check()
5115 skb->inner_protocol_type != ENCAP_TYPE_ETHER || in be_features_check()
5116 skb->inner_protocol != htons(ETH_P_TEB) || in be_features_check()
5117 skb_inner_mac_header(skb) - skb_transport_header(skb) != in be_features_check()
5119 !adapter->vxlan_port || in be_features_check()
5120 udp_hdr(skb)->dest != adapter->vxlan_port) in be_features_check()
5134 return -ENOSPC; in be_get_phys_port_id()
5136 ppid->id[0] = adapter->hba_port_num + 1; in be_get_phys_port_id()
5137 id = &ppid->id[1]; in be_get_phys_port_id()
5138 for (i = CNTL_SERIAL_NUM_WORDS - 1; i >= 0; in be_get_phys_port_id()
5139 i--, id += CNTL_SERIAL_NUM_WORD_SZ) in be_get_phys_port_id()
5140 memcpy(id, &adapter->serial_num[i], CNTL_SERIAL_NUM_WORD_SZ); in be_get_phys_port_id()
5142 ppid->id_len = id_len; in be_get_phys_port_id()
5154 queue_work(be_wq, &work->work); in be_set_rx_mode()
5187 netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | in be_netdev_init()
5192 netdev->hw_features |= NETIF_F_RXHASH; in be_netdev_init()
5194 netdev->features |= netdev->hw_features | in be_netdev_init()
5198 netdev->vlan_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | in be_netdev_init()
5201 netdev->priv_flags |= IFF_UNICAST_FLT; in be_netdev_init()
5203 netdev->flags |= IFF_MULTICAST; in be_netdev_init()
5205 netif_set_tso_max_size(netdev, BE_MAX_GSO_SIZE - ETH_HLEN); in be_netdev_init()
5207 netdev->netdev_ops = &be_netdev_ops; in be_netdev_init()
5209 netdev->ethtool_ops = &be_ethtool_ops; in be_netdev_init()
5212 netdev->udp_tunnel_nic_info = &be_udp_tunnels; in be_netdev_init()
5214 /* MTU range: 256 - 9000 */ in be_netdev_init()
5215 netdev->min_mtu = BE_MIN_MTU; in be_netdev_init()
5216 netdev->max_mtu = BE_MAX_MTU; in be_netdev_init()
5221 struct net_device *netdev = adapter->netdev; in be_cleanup()
5234 struct net_device *netdev = adapter->netdev; in be_resume()
5258 dev_info(&adapter->pdev->dev, "Initiating chip soft reset\n"); in be_soft_reset()
5259 val = ioread32(adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5261 iowrite32(val, adapter->pcicfg + SLIPORT_SOFTRESET_OFFSET); in be_soft_reset()
5266 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_err_is_recoverable()
5281 dev_err(&adapter->pdev->dev, "Recoverable HW error code: 0x%x\n", in be_err_is_recoverable()
5284 if (time_before_eq(jiffies - err_rec->probe_time, initial_idle_time)) { in be_err_is_recoverable()
5285 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5291 if (err_rec->last_recovery_time && time_before_eq( in be_err_is_recoverable()
5292 jiffies - err_rec->last_recovery_time, recovery_interval)) { in be_err_is_recoverable()
5293 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5299 if (ue_err_code == err_rec->last_err_code) { in be_err_is_recoverable()
5300 dev_err(&adapter->pdev->dev, in be_err_is_recoverable()
5305 err_rec->last_recovery_time = jiffies; in be_err_is_recoverable()
5306 err_rec->last_err_code = ue_err_code; in be_err_is_recoverable()
5312 struct be_error_recovery *err_rec = &adapter->error_recovery; in be_tpe_recover()
5313 int status = -EAGAIN; in be_tpe_recover()
5316 switch (err_rec->recovery_state) { in be_tpe_recover()
5318 err_rec->recovery_state = ERR_RECOVERY_ST_DETECT; in be_tpe_recover()
5319 err_rec->resched_delay = ERR_RECOVERY_UE_DETECT_DURATION; in be_tpe_recover()
5326 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5328 status = -EINVAL; in be_tpe_recover()
5329 err_rec->resched_delay = 0; in be_tpe_recover()
5333 dev_err(&adapter->pdev->dev, "Recoverable HW error detected\n"); in be_tpe_recover()
5340 if (adapter->pf_num == 0) { in be_tpe_recover()
5341 err_rec->recovery_state = ERR_RECOVERY_ST_RESET; in be_tpe_recover()
5342 err_rec->resched_delay = err_rec->ue_to_reset_time - in be_tpe_recover()
5347 err_rec->recovery_state = ERR_RECOVERY_ST_PRE_POLL; in be_tpe_recover()
5348 err_rec->resched_delay = err_rec->ue_to_poll_time - in be_tpe_recover()
5354 dev_err(&adapter->pdev->dev, in be_tpe_recover()
5356 status = -EIO; in be_tpe_recover()
5357 err_rec->resched_delay = 0; in be_tpe_recover()
5361 err_rec->recovery_state = ERR_RECOVERY_ST_PRE_POLL; in be_tpe_recover()
5362 err_rec->resched_delay = err_rec->ue_to_poll_time - in be_tpe_recover()
5363 err_rec->ue_to_reset_time; in be_tpe_recover()
5367 err_rec->recovery_state = ERR_RECOVERY_ST_REINIT; in be_tpe_recover()
5368 err_rec->resched_delay = 0; in be_tpe_recover()
5373 status = -EINVAL; in be_tpe_recover()
5374 err_rec->resched_delay = 0; in be_tpe_recover()
5386 if (!adapter->error_recovery.recovery_supported || in be_err_recover()
5387 adapter->priv_flags & BE_DISABLE_TPE_RECOVERY) in be_err_recover()
5388 return -EIO; in be_err_recover()
5401 adapter->flags |= BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5409 adapter->flags &= ~BE_FLAGS_TRY_RECOVERY; in be_err_recover()
5424 struct device *dev = &adapter->pdev->dev; in be_err_detection_task()
5433 err_rec->recovery_retries = 0; in be_err_detection_task()
5434 err_rec->recovery_state = ERR_RECOVERY_ST_NONE; in be_err_detection_task()
5437 } else if (!lancer_chip(adapter) && err_rec->resched_delay) { in be_err_detection_task()
5439 if (adapter->pf_num == 0 && in be_err_detection_task()
5440 err_rec->recovery_state > ERR_RECOVERY_ST_DETECT) in be_err_detection_task()
5441 dev_err(&adapter->pdev->dev, in be_err_detection_task()
5443 resched_delay = err_rec->resched_delay; in be_err_detection_task()
5449 dev_err(dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5451 } else if (lancer_chip(adapter) && err_rec->recovery_retries++ < in be_err_detection_task()
5457 dev_err(&adapter->pdev->dev, "Re-trying adapter recovery\n"); in be_err_detection_task()
5477 dev_err(&adapter->pdev->dev, in be_log_sfp_info()
5479 adapter->port_name, in be_log_sfp_info()
5480 be_misconfig_evt_port_state[adapter->phy_state], in be_log_sfp_info()
5481 adapter->phy.vendor_name, in be_log_sfp_info()
5482 adapter->phy.vendor_pn); in be_log_sfp_info()
5484 adapter->flags &= ~BE_FLAGS_PHY_MISCONFIGURED; in be_log_sfp_info()
5495 MODULO(adapter->work_counter, adapter->be_get_temp_freq) == 0) in be_worker()
5501 if (!netif_running(adapter->netdev)) { in be_worker()
5508 if (!adapter->stats_cmd_sent) { in be_worker()
5511 &adapter->stats_cmd); in be_worker()
5513 be_cmd_get_stats(adapter, &adapter->stats_cmd); in be_worker()
5517 /* Replenish RX-queues starved due to memory in be_worker()
5520 if (rxo->rx_post_starved) in be_worker()
5524 /* EQ-delay update for Skyhawk is done while notifying EQ */ in be_worker()
5528 if (adapter->flags & BE_FLAGS_PHY_MISCONFIGURED) in be_worker()
5532 adapter->work_counter++; in be_worker()
5533 queue_delayed_work(be_wq, &adapter->work, msecs_to_jiffies(1000)); in be_worker()
5538 if (adapter->csr) in be_unmap_pci_bars()
5539 pci_iounmap(adapter->pdev, adapter->csr); in be_unmap_pci_bars()
5540 if (adapter->db) in be_unmap_pci_bars()
5541 pci_iounmap(adapter->pdev, adapter->db); in be_unmap_pci_bars()
5542 if (adapter->pcicfg && adapter->pcicfg_mapped) in be_unmap_pci_bars()
5543 pci_iounmap(adapter->pdev, adapter->pcicfg); in be_unmap_pci_bars()
5557 adapter->roce_db.size = 4096; in be_roce_map_pci_bars()
5558 adapter->roce_db.io_addr = pci_resource_start(adapter->pdev, in be_roce_map_pci_bars()
5560 adapter->roce_db.total_size = pci_resource_len(adapter->pdev, in be_roce_map_pci_bars()
5568 struct pci_dev *pdev = adapter->pdev; in be_map_pci_bars()
5572 pci_read_config_dword(adapter->pdev, SLI_INTF_REG_OFFSET, &sli_intf); in be_map_pci_bars()
5573 adapter->sli_family = (sli_intf & SLI_INTF_FAMILY_MASK) >> in be_map_pci_bars()
5575 adapter->virtfn = (sli_intf & SLI_INTF_FT_MASK) ? 1 : 0; in be_map_pci_bars()
5578 adapter->csr = pci_iomap(pdev, 2, 0); in be_map_pci_bars()
5579 if (!adapter->csr) in be_map_pci_bars()
5580 return -ENOMEM; in be_map_pci_bars()
5586 adapter->db = addr; in be_map_pci_bars()
5594 adapter->pcicfg = addr; in be_map_pci_bars()
5595 adapter->pcicfg_mapped = true; in be_map_pci_bars()
5597 adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET; in be_map_pci_bars()
5598 adapter->pcicfg_mapped = false; in be_map_pci_bars()
5606 dev_err(&pdev->dev, "Error in mapping PCI BARs\n"); in be_map_pci_bars()
5608 return -ENOMEM; in be_map_pci_bars()
5613 struct be_dma_mem *mem = &adapter->mbox_mem_alloced; in be_drv_cleanup()
5614 struct device *dev = &adapter->pdev->dev; in be_drv_cleanup()
5616 if (mem->va) in be_drv_cleanup()
5617 dma_free_coherent(dev, mem->size, mem->va, mem->dma); in be_drv_cleanup()
5619 mem = &adapter->rx_filter; in be_drv_cleanup()
5620 if (mem->va) in be_drv_cleanup()
5621 dma_free_coherent(dev, mem->size, mem->va, mem->dma); in be_drv_cleanup()
5623 mem = &adapter->stats_cmd; 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()
5631 struct be_dma_mem *mbox_mem_alloc = &adapter->mbox_mem_alloced; in be_drv_init()
5632 struct be_dma_mem *mbox_mem_align = &adapter->mbox_mem; in be_drv_init()
5633 struct be_dma_mem *rx_filter = &adapter->rx_filter; in be_drv_init()
5634 struct be_dma_mem *stats_cmd = &adapter->stats_cmd; in be_drv_init()
5635 struct device *dev = &adapter->pdev->dev; in be_drv_init()
5638 mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16; in be_drv_init()
5639 mbox_mem_alloc->va = dma_alloc_coherent(dev, mbox_mem_alloc->size, in be_drv_init()
5640 &mbox_mem_alloc->dma, in be_drv_init()
5642 if (!mbox_mem_alloc->va) in be_drv_init()
5643 return -ENOMEM; in be_drv_init()
5645 mbox_mem_align->size = sizeof(struct be_mcc_mailbox); in be_drv_init()
5646 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); in be_drv_init()
5647 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); in be_drv_init()
5649 rx_filter->size = sizeof(struct be_cmd_req_rx_filter); in be_drv_init()
5650 rx_filter->va = dma_alloc_coherent(dev, rx_filter->size, in be_drv_init()
5651 &rx_filter->dma, GFP_KERNEL); in be_drv_init()
5652 if (!rx_filter->va) { in be_drv_init()
5653 status = -ENOMEM; in be_drv_init()
5658 stats_cmd->size = sizeof(struct lancer_cmd_req_pport_stats); in be_drv_init()
5660 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v0); in be_drv_init()
5662 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v1); in be_drv_init()
5664 stats_cmd->size = sizeof(struct be_cmd_req_get_stats_v2); in be_drv_init()
5665 stats_cmd->va = dma_alloc_coherent(dev, stats_cmd->size, in be_drv_init()
5666 &stats_cmd->dma, GFP_KERNEL); in be_drv_init()
5667 if (!stats_cmd->va) { in be_drv_init()
5668 status = -ENOMEM; in be_drv_init()
5672 mutex_init(&adapter->mbox_lock); in be_drv_init()
5673 mutex_init(&adapter->mcc_lock); in be_drv_init()
5674 mutex_init(&adapter->rx_filter_lock); in be_drv_init()
5675 spin_lock_init(&adapter->mcc_cq_lock); in be_drv_init()
5676 init_completion(&adapter->et_cmd_compl); in be_drv_init()
5678 pci_save_state(adapter->pdev); in be_drv_init()
5680 INIT_DELAYED_WORK(&adapter->work, be_worker); in be_drv_init()
5682 adapter->error_recovery.recovery_state = ERR_RECOVERY_ST_NONE; in be_drv_init()
5683 adapter->error_recovery.resched_delay = 0; in be_drv_init()
5684 INIT_DELAYED_WORK(&adapter->error_recovery.err_detection_work, in be_drv_init()
5687 adapter->rx_fc = true; in be_drv_init()
5688 adapter->tx_fc = true; in be_drv_init()
5691 adapter->be_get_temp_freq = 64; in be_drv_init()
5696 dma_free_coherent(dev, rx_filter->size, rx_filter->va, rx_filter->dma); in be_drv_init()
5698 dma_free_coherent(dev, mbox_mem_alloc->size, mbox_mem_alloc->va, in be_drv_init()
5699 mbox_mem_alloc->dma); in be_drv_init()
5715 unregister_netdev(adapter->netdev); in be_remove()
5719 if (!pci_vfs_assigned(adapter->pdev)) in be_remove()
5731 free_netdev(adapter->netdev); in be_remove()
5741 if (adapter->hwmon_info.be_on_die_temp == BE_INVALID_DIE_TEMP) in be_hwmon_show_temp()
5742 return -EIO; in be_hwmon_show_temp()
5745 adapter->hwmon_info.be_on_die_temp * 1000); in be_hwmon_show_temp()
5762 switch (adapter->mc_type) { in mc_name()
5770 str = "vNIC-1"; in mc_name()
5779 str = "vNIC-2"; in mc_name()
5795 switch (pdev->device) { in nic_name()
5830 status = -ENOMEM; in be_probe()
5834 adapter->pdev = pdev; in be_probe()
5836 adapter->netdev = netdev; in be_probe()
5837 SET_NETDEV_DEV(netdev, &pdev->dev); in be_probe()
5839 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in be_probe()
5841 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n"); in be_probe()
5865 adapter->error_recovery.probe_time = jiffies; in be_probe()
5869 adapter->hwmon_info.hwmon_dev = in be_probe()
5870 devm_hwmon_device_register_with_groups(&pdev->dev, in be_probe()
5874 adapter->hwmon_info.be_on_die_temp = BE_INVALID_DIE_TEMP; in be_probe()
5877 dev_info(&pdev->dev, "%s: %s %s port %c\n", nic_name(pdev), in be_probe()
5878 func_name(adapter), mc_name(adapter), adapter->port_name); in be_probe()
5895 dev_err(&pdev->dev, "%s initialization failed\n", nic_name(pdev)); in be_probe()
5936 cancel_delayed_work_sync(&adapter->work); in be_shutdown()
5939 netif_device_detach(adapter->netdev); in be_shutdown()
5951 dev_err(&adapter->pdev->dev, "EEH error detected\n"); in be_eeh_err_detected()
5974 if (pdev->devfn == 0) in be_eeh_err_detected()
5985 dev_info(&adapter->pdev->dev, "EEH reset\n"); in be_eeh_reset()
5995 dev_info(&adapter->pdev->dev, in be_eeh_reset()
6010 dev_info(&adapter->pdev->dev, "EEH resume\n"); in be_eeh_resume()
6023 dev_err(&adapter->pdev->dev, "EEH resume failed\n"); in be_eeh_resume()
6035 adapter->num_vfs = num_vfs; in be_pci_sriov_configure()
6037 if (adapter->num_vfs == 0 && pci_vfs_assigned(pdev)) { in be_pci_sriov_configure()
6038 dev_warn(&pdev->dev, in be_pci_sriov_configure()
6040 return -EBUSY; in be_pci_sriov_configure()
6043 /* When the HW is in SRIOV capable configuration, the PF-pool resources in be_pci_sriov_configure()
6044 * are equally distributed across the max-number of VFs. The user may in be_pci_sriov_configure()
6045 * request only a subset of the max-vfs to be enabled. in be_pci_sriov_configure()
6052 be_calculate_vf_res(adapter, adapter->num_vfs, in be_pci_sriov_configure()
6054 status = be_cmd_set_sriov_config(adapter, adapter->pool_res, in be_pci_sriov_configure()
6055 adapter->num_vfs, &vft_res); in be_pci_sriov_configure()
6057 dev_err(&pdev->dev, in be_pci_sriov_configure()
6058 "Failed to optimize SR-IOV resources\n"); in be_pci_sriov_configure()
6072 if (adapter->num_vfs) in be_pci_sriov_configure()
6076 return adapter->num_vfs; in be_pci_sriov_configure()
6120 return -1; in be_init_module()