Lines Matching full:nic
2 * s2io.c: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC
558 * @nic: Device private variable.
560 * between the NIC and the driver. This includes Tx descriptors,
564 static int init_shared_mem(struct s2io_nic *nic) in init_shared_mem() argument
572 struct net_device *dev = nic->dev; in init_shared_mem()
575 struct config_param *config = &nic->config; in init_shared_mem()
576 struct mac_info *mac_control = &nic->mac_control; in init_shared_mem()
636 fifo->nic = nic; in init_shared_mem()
644 tmp_v = dma_alloc_coherent(&nic->pdev->dev, PAGE_SIZE, in init_shared_mem()
662 tmp_v = dma_alloc_coherent(&nic->pdev->dev, in init_shared_mem()
702 if (rx_cfg->num_rxd % (rxd_count[nic->rxd_mode] + 1)) { in init_shared_mem()
710 (rxd_count[nic->rxd_mode] + 1); in init_shared_mem()
713 if (nic->rxd_mode == RXD_MODE_1) in init_shared_mem()
728 ring->nic = nic; in init_shared_mem()
731 blk_cnt = rx_cfg->num_rxd / (rxd_count[nic->rxd_mode] + 1); in init_shared_mem()
739 tmp_v_addr = dma_alloc_coherent(&nic->pdev->dev, size, in init_shared_mem()
754 rxd_count[nic->rxd_mode]; in init_shared_mem()
761 for (l = 0; l < rxd_count[nic->rxd_mode]; l++) { in init_shared_mem()
764 (rxd_size[nic->rxd_mode] * l); in init_shared_mem()
767 (rxd_size[nic->rxd_mode] * l); in init_shared_mem()
785 if (nic->rxd_mode == RXD_MODE_3B) { in init_shared_mem()
795 (rxd_count[nic->rxd_mode] + 1); in init_shared_mem()
805 (rxd_count[nic->rxd_mode] + 1); in init_shared_mem()
810 while (k != rxd_count[nic->rxd_mode]) { in init_shared_mem()
840 dma_alloc_coherent(&nic->pdev->dev, size, in init_shared_mem()
858 dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr); in init_shared_mem()
865 * @nic: Device private variable.
870 static void free_shared_mem(struct s2io_nic *nic) in free_shared_mem() argument
883 if (!nic) in free_shared_mem()
886 dev = nic->dev; in free_shared_mem()
888 config = &nic->config; in free_shared_mem()
889 mac_control = &nic->mac_control; in free_shared_mem()
911 dma_free_coherent(&nic->pdev->dev, PAGE_SIZE, in free_shared_mem()
920 dma_free_coherent(&nic->pdev->dev, PAGE_SIZE, in free_shared_mem()
944 dma_free_coherent(&nic->pdev->dev, size, tmp_v_addr, in free_shared_mem()
949 rxd_count[nic->rxd_mode]; in free_shared_mem()
953 if (nic->rxd_mode == RXD_MODE_3B) { in free_shared_mem()
960 (rxd_count[nic->rxd_mode] + 1); in free_shared_mem()
965 while (k != rxd_count[nic->rxd_mode]) { in free_shared_mem()
977 (rxd_count[nic->rxd_mode] + 1); in free_shared_mem()
985 for (i = 0; i < nic->config.tx_fifo_num; i++) { in free_shared_mem()
998 dma_free_coherent(&nic->pdev->dev, mac_control->stats_mem_sz, in free_shared_mem()
1008 static int s2io_verify_pci_mode(struct s2io_nic *nic) in s2io_verify_pci_mode() argument
1010 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_verify_pci_mode()
1042 static int s2io_print_pci_mode(struct s2io_nic *nic) in s2io_print_pci_mode() argument
1044 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_print_pci_mode()
1047 struct config_param *config = &nic->config; in s2io_print_pci_mode()
1058 if (s2io_on_nec_bridge(nic->pdev)) { in s2io_print_pci_mode()
1060 nic->dev->name); in s2io_print_pci_mode()
1095 nic->dev->name, val64 & PCI_MODE_32_BITS ? 32 : 64, pcimode); in s2io_print_pci_mode()
1102 * @nic: device private variable
1112 static int init_tti(struct s2io_nic *nic, int link, bool may_sleep) in init_tti() argument
1114 struct XENA_dev_config __iomem *bar0 = nic->bar0; in init_tti()
1117 struct config_param *config = &nic->config; in init_tti()
1125 if (nic->device_type == XFRAME_II_DEVICE) { in init_tti()
1126 int count = (nic->config.bus_speed * 125)/2; in init_tti()
1140 if (nic->config.intr_type == MSI_X) { in init_tti()
1146 if ((nic->config.tx_steering_type == in init_tti()
1149 (i >= nic->udp_fifo_idx) && in init_tti()
1150 (i < (nic->udp_fifo_idx + in init_tti()
1151 nic->total_udp_fifos))) in init_tti()
1181 * @nic: device private variable
1188 static int init_nic(struct s2io_nic *nic) in init_nic() argument
1190 struct XENA_dev_config __iomem *bar0 = nic->bar0; in init_nic()
1191 struct net_device *dev = nic->dev; in init_nic()
1199 struct config_param *config = &nic->config; in init_nic()
1200 struct mac_info *mac_control = &nic->mac_control; in init_nic()
1203 if (s2io_set_swapper(nic)) { in init_nic()
1211 if (nic->device_type & XFRAME_II_DEVICE) { in init_nic()
1227 if (nic->device_type == XFRAME_II_DEVICE) { in init_nic()
1256 if (nic->device_type & XFRAME_II_DEVICE) { in init_nic()
1322 if ((nic->device_type == XFRAME_I_DEVICE) && (nic->pdev->revision < 4)) in init_nic()
1354 if (nic->device_type & XFRAME_II_DEVICE) in init_nic()
1635 if (rts_ds_steer(nic, i, 0) == FAILURE) { in init_nic()
1646 if (nic->device_type == XFRAME_II_DEVICE) { in init_nic()
1665 if (SUCCESS != init_tti(nic, nic->last_link_state, true)) in init_nic()
1669 if (nic->device_type == XFRAME_II_DEVICE) { in init_nic()
1674 int count = (nic->config.bus_speed * 125)/4; in init_nic()
1687 if (nic->config.intr_type == MSI_X) in init_nic()
1745 if (nic->device_type == XFRAME_II_DEVICE) in init_nic()
1760 val64 |= RMAC_PAUSE_HG_PTIME(nic->mac_control.rmac_pause_time); in init_nic()
1772 nic->mac_control.mc_pause_threshold_q0q3) in init_nic()
1780 nic->mac_control.mc_pause_threshold_q4q7) in init_nic()
1793 if (nic->config.bus_speed == 266) { in init_nic()
1803 if (nic->device_type == XFRAME_II_DEVICE) { in init_nic()
1811 if (strstr(nic->product_name, "CX4")) { in init_nic()
1821 static int s2io_link_fault_indication(struct s2io_nic *nic) in s2io_link_fault_indication() argument
1823 if (nic->device_type == XFRAME_II_DEVICE) in s2io_link_fault_indication()
1851 static void en_dis_err_alarms(struct s2io_nic *nic, u16 mask, int flag) in en_dis_err_alarms() argument
1853 struct XENA_dev_config __iomem *bar0 = nic->bar0; in en_dis_err_alarms()
1950 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) in en_dis_err_alarms()
1972 nic->general_int_mask = gen_int_mask; in en_dis_err_alarms()
1975 nic->general_int_mask = 0; in en_dis_err_alarms()
1980 * @nic: device private variable,
1989 static void en_dis_able_nic_intrs(struct s2io_nic *nic, u16 mask, int flag) in en_dis_able_nic_intrs() argument
1991 struct XENA_dev_config __iomem *bar0 = nic->bar0; in en_dis_able_nic_intrs()
1994 intr_mask = nic->general_int_mask; in en_dis_able_nic_intrs()
2008 if (s2io_link_fault_indication(nic) == in en_dis_able_nic_intrs()
2065 nic->general_int_mask = readq(&bar0->general_int_mask); in en_dis_able_nic_intrs()
2199 * @nic : device private variable.
2203 * and shared memory is allocated but the NIC is still quiescent. On
2204 * calling this function, the device interrupts are cleared and the NIC is
2210 static int start_nic(struct s2io_nic *nic) in start_nic() argument
2212 struct XENA_dev_config __iomem *bar0 = nic->bar0; in start_nic()
2213 struct net_device *dev = nic->dev; in start_nic()
2216 struct config_param *config = &nic->config; in start_nic()
2217 struct mac_info *mac_control = &nic->mac_control; in start_nic()
2227 if (nic->rxd_mode == RXD_MODE_1) in start_nic()
2231 if (nic->device_type == XFRAME_II_DEVICE) in start_nic()
2238 if (nic->rxd_mode == RXD_MODE_3B) { in start_nic()
2249 nic->vlan_strip_flag = 0; in start_nic()
2274 if (!verify_xena_quiescence(nic)) { in start_nic()
2294 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) { in start_nic()
2299 schedule_work(&nic->set_link_task); in start_nic()
2302 subid = nic->pdev->subsystem_device; in start_nic()
2304 (nic->device_type == XFRAME_I_DEVICE)) { in start_nic()
2323 struct s2io_nic *nic = fifo_data->nic; in s2io_txdl_getskb() local
2330 dma_unmap_single(&nic->pdev->dev, in s2io_txdl_getskb()
2341 dma_unmap_single(&nic->pdev->dev, (dma_addr_t)txds->Buffer_Pointer, in s2io_txdl_getskb()
2350 dma_unmap_page(&nic->pdev->dev, in s2io_txdl_getskb()
2361 * @nic : device private variable.
2367 static void free_tx_buffers(struct s2io_nic *nic) in free_tx_buffers() argument
2369 struct net_device *dev = nic->dev; in free_tx_buffers()
2374 struct config_param *config = &nic->config; in free_tx_buffers()
2375 struct mac_info *mac_control = &nic->mac_control; in free_tx_buffers()
2404 * stop_nic - To stop the nic
2405 * @nic : device private variable.
2413 static void stop_nic(struct s2io_nic *nic) in stop_nic() argument
2415 struct XENA_dev_config __iomem *bar0 = nic->bar0; in stop_nic()
2420 en_dis_err_alarms(nic, ENA_ALL_INTRS, DISABLE_INTRS); in stop_nic()
2423 en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS); in stop_nic()
2433 * @nic : device private variable.
2440 * address of these buffers into the RxD buffer pointers, so that the NIC
2442 * The NIC supports 3 receive modes, viz
2447 * up into by the NIC. The frame is split into L3 header, L4 Header,
2454 static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring, in fill_rx_buffers() argument
2468 struct swStat *swstats = &ring->nic->mac_control.stats_info->sw_stat; in fill_rx_buffers()
2517 skb = netdev_alloc_skb(nic->dev, size); in fill_rx_buffers()
2540 if (dma_mapping_error(&nic->pdev->dev, rxdp1->Buffer0_ptr)) in fill_rx_buffers()
2575 if (dma_mapping_error(&nic->pdev->dev, rxdp3->Buffer0_ptr)) in fill_rx_buffers()
2596 if (dma_mapping_error(&nic->pdev->dev, rxdp3->Buffer2_ptr)) in fill_rx_buffers()
2606 if (dma_mapping_error(&nic->pdev->dev, in fill_rx_buffers()
2739 static int s2io_chk_rx_buffers(struct s2io_nic *nic, struct ring_info *ring) in s2io_chk_rx_buffers() argument
2741 if (fill_rx_buffers(nic, ring, 0) == -ENOMEM) { in s2io_chk_rx_buffers()
2768 struct s2io_nic *nic = netdev_priv(dev); in s2io_poll_msix() local
2769 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_poll_msix()
2772 if (unlikely(!is_s2io_card_up(nic))) in s2io_poll_msix()
2776 s2io_chk_rx_buffers(nic, ring); in s2io_poll_msix()
2792 struct s2io_nic *nic = container_of(napi, struct s2io_nic, napi); in s2io_poll_inta() local
2795 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_poll_inta()
2797 struct config_param *config = &nic->config; in s2io_poll_inta()
2798 struct mac_info *mac_control = &nic->mac_control; in s2io_poll_inta()
2800 if (unlikely(!is_s2io_card_up(nic))) in s2io_poll_inta()
2806 s2io_chk_rx_buffers(nic, ring); in s2io_poll_inta()
2833 struct s2io_nic *nic = netdev_priv(dev); in s2io_netpoll() local
2834 const int irq = nic->pdev->irq; in s2io_netpoll()
2835 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_netpoll()
2838 struct config_param *config = &nic->config; in s2io_netpoll()
2839 struct mac_info *mac_control = &nic->mac_control; in s2io_netpoll()
2841 if (pci_channel_offline(nic->pdev)) in s2io_netpoll()
2866 if (fill_rx_buffers(nic, ring, 0) == -ENOMEM) { in s2io_netpoll()
2961 if (ring_data->nic->config.napi) { in rx_intr_handler()
2976 update_L3L4_header(ring_data->nic, lro); in rx_intr_handler()
2999 struct s2io_nic *nic = fifo_data->nic; in tx_intr_handler() local
3006 struct stat_block *stats = nic->mac_control.stats_info; in tx_intr_handler()
3071 s2io_wake_tx_queue(fifo_data, pkt_cnt, nic->config.multiq); in tx_intr_handler()
3195 "Take Xframe NIC out of service.\n"); in s2io_chk_xpak_counter()
3201 "Take Xframe NIC out of service.\n"); in s2io_chk_xpak_counter()
3207 "Take Xframe NIC out of service.\n"); in s2io_chk_xpak_counter()
3656 static int wait_for_msix_trans(struct s2io_nic *nic, int i) in wait_for_msix_trans() argument
3658 struct XENA_dev_config __iomem *bar0 = nic->bar0; in wait_for_msix_trans()
3677 static void restore_xmsi_data(struct s2io_nic *nic) in restore_xmsi_data() argument
3679 struct XENA_dev_config __iomem *bar0 = nic->bar0; in restore_xmsi_data()
3683 if (nic->device_type == XFRAME_I_DEVICE) in restore_xmsi_data()
3688 writeq(nic->msix_info[i].addr, &bar0->xmsi_address); in restore_xmsi_data()
3689 writeq(nic->msix_info[i].data, &bar0->xmsi_data); in restore_xmsi_data()
3692 if (wait_for_msix_trans(nic, msix_index)) in restore_xmsi_data()
3698 static void store_xmsi_data(struct s2io_nic *nic) in store_xmsi_data() argument
3700 struct XENA_dev_config __iomem *bar0 = nic->bar0; in store_xmsi_data()
3704 if (nic->device_type == XFRAME_I_DEVICE) in store_xmsi_data()
3712 if (wait_for_msix_trans(nic, msix_index)) { in store_xmsi_data()
3720 nic->msix_info[i].addr = addr; in store_xmsi_data()
3721 nic->msix_info[i].data = data; in store_xmsi_data()
3726 static int s2io_enable_msi_x(struct s2io_nic *nic) in s2io_enable_msi_x() argument
3728 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_enable_msi_x()
3733 struct stat_block *stats = nic->mac_control.stats_info; in s2io_enable_msi_x()
3736 size = nic->num_entries * sizeof(struct msix_entry); in s2io_enable_msi_x()
3737 nic->entries = kzalloc(size, GFP_KERNEL); in s2io_enable_msi_x()
3738 if (!nic->entries) { in s2io_enable_msi_x()
3746 size = nic->num_entries * sizeof(struct s2io_msix_entry); in s2io_enable_msi_x()
3747 nic->s2io_entries = kzalloc(size, GFP_KERNEL); in s2io_enable_msi_x()
3748 if (!nic->s2io_entries) { in s2io_enable_msi_x()
3752 kfree(nic->entries); in s2io_enable_msi_x()
3754 += (nic->num_entries * sizeof(struct msix_entry)); in s2io_enable_msi_x()
3759 nic->entries[0].entry = 0; in s2io_enable_msi_x()
3760 nic->s2io_entries[0].entry = 0; in s2io_enable_msi_x()
3761 nic->s2io_entries[0].in_use = MSIX_FLG; in s2io_enable_msi_x()
3762 nic->s2io_entries[0].type = MSIX_ALARM_TYPE; in s2io_enable_msi_x()
3763 nic->s2io_entries[0].arg = &nic->mac_control.fifos; in s2io_enable_msi_x()
3765 for (i = 1; i < nic->num_entries; i++) { in s2io_enable_msi_x()
3766 nic->entries[i].entry = ((i - 1) * 8) + 1; in s2io_enable_msi_x()
3767 nic->s2io_entries[i].entry = ((i - 1) * 8) + 1; in s2io_enable_msi_x()
3768 nic->s2io_entries[i].arg = NULL; in s2io_enable_msi_x()
3769 nic->s2io_entries[i].in_use = 0; in s2io_enable_msi_x()
3773 for (j = 0; j < nic->config.rx_ring_num; j++) { in s2io_enable_msi_x()
3775 nic->s2io_entries[j+1].arg = &nic->mac_control.rings[j]; in s2io_enable_msi_x()
3776 nic->s2io_entries[j+1].type = MSIX_RING_TYPE; in s2io_enable_msi_x()
3777 nic->s2io_entries[j+1].in_use = MSIX_FLG; in s2io_enable_msi_x()
3783 ret = pci_enable_msix_range(nic->pdev, nic->entries, in s2io_enable_msi_x()
3784 nic->num_entries, nic->num_entries); in s2io_enable_msi_x()
3788 kfree(nic->entries); in s2io_enable_msi_x()
3789 swstats->mem_freed += nic->num_entries * in s2io_enable_msi_x()
3791 kfree(nic->s2io_entries); in s2io_enable_msi_x()
3792 swstats->mem_freed += nic->num_entries * in s2io_enable_msi_x()
3794 nic->entries = NULL; in s2io_enable_msi_x()
3795 nic->s2io_entries = NULL; in s2io_enable_msi_x()
3801 * in the herc NIC. (Temp change, needs to be removed later) in s2io_enable_msi_x()
3803 pci_read_config_word(nic->pdev, 0x42, &msi_control); in s2io_enable_msi_x()
3805 pci_write_config_word(nic->pdev, 0x42, msi_control); in s2io_enable_msi_x()
3904 * descriptors and then enables the Rx part of the NIC.
3918 * Nic is initialized in s2io_open()
3963 * Rx side of the NIC and frees all the Rx buffers in the Rx rings.
4000 * This function is the Tx entry point of the driver. S2IO NIC supports
4208 struct s2io_nic *sp = ring->nic; in s2io_msix_ring_handle()
4236 struct s2io_nic *sp = fifos->nic; in s2io_msix_fifo_handle()
4653 * @dev_id: a void pointer to the dev structure of the NIC.
4936 /* Put the NIC into promiscuous mode */ in s2io_set_multicast()
4958 /* Remove the NIC from promiscuous mode */ in s2io_set_multicast()
5268 * the NIC.
5357 * Dumps the entire register space of xFrame NIC into the user given
5381 * s2io_set_led - control NIC led
5411 * s2io_ethtool_set_led - To physically identify the nic on the system.
5415 * Description: Used to physically identify the NIC on the system.
5493 * Returns the Pause frame generation and reception capability of the NIC.
5518 * support of the NIC.
5677 static void s2io_vpd_read(struct s2io_nic *nic) in s2io_vpd_read() argument
5683 struct swStat *swstats = &nic->mac_control.stats_info->sw_stat; in s2io_vpd_read()
5685 if (nic->device_type == XFRAME_II_DEVICE) { in s2io_vpd_read()
5686 strcpy(nic->product_name, "Xframe II 10GbE network adapter"); in s2io_vpd_read()
5689 strcpy(nic->product_name, "Xframe I 10GbE network adapter"); in s2io_vpd_read()
5692 strcpy(nic->serial_num, "NOT AVAILABLE"); in s2io_vpd_read()
5702 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); in s2io_vpd_read()
5703 pci_read_config_byte(nic->pdev, (vpd_addr + 2), &data); in s2io_vpd_read()
5704 pci_write_config_byte(nic->pdev, (vpd_addr + 3), 0); in s2io_vpd_read()
5707 pci_read_config_byte(nic->pdev, (vpd_addr + 3), &data); in s2io_vpd_read()
5716 pci_read_config_dword(nic->pdev, (vpd_addr + 4), in s2io_vpd_read()
5727 memcpy(nic->serial_num, in s2io_vpd_read()
5730 memset(nic->serial_num+len, in s2io_vpd_read()
5741 memcpy(nic->product_name, &vpd_data[3], len); in s2io_vpd_read()
5742 nic->product_name[len] = 0; in s2io_vpd_read()
5841 * Read and write into all clock domains. The NIC has 3 clock domains,
6040 * s2io_link_test - verifies the link state of the nic
6046 * The function verifies the link state of the NIC and updates the input
6067 * s2io_rldram_test - offline test for access to the RldRam chip on the NIC
6074 * access to the RldRam chip on the NIC.
6669 struct s2io_nic *nic = container_of(work, struct s2io_nic, in s2io_set_link() local
6671 struct net_device *dev = nic->dev; in s2io_set_link()
6672 struct XENA_dev_config __iomem *bar0 = nic->bar0; in s2io_set_link()
6681 if (test_and_set_bit(__S2IO_STATE_LINK_TASK, &(nic->state))) { in s2io_set_link()
6686 subid = nic->pdev->subsystem_device; in s2io_set_link()
6687 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) { in s2io_set_link()
6698 if (verify_xena_quiescence(nic)) { in s2io_set_link()
6703 nic->device_type, subid)) { in s2io_set_link()
6712 nic->device_enabled_once = true; in s2io_set_link()
6717 s2io_stop_all_tx_queue(nic); in s2io_set_link()
6723 s2io_link(nic, LINK_UP); in s2io_set_link()
6725 if (CARDS_WITH_FAULTY_LINK_INDICATORS(nic->device_type, in s2io_set_link()
6736 s2io_link(nic, LINK_DOWN); in s2io_set_link()
6738 clear_bit(__S2IO_STATE_LINK_TASK, &(nic->state)); in s2io_set_link()
7039 /* disable Tx and Rx traffic on the NIC */ in do_s2io_card_down()
7048 /* Check if the device is Quiescent and then Reset the NIC */ in do_s2io_card_down()
7161 /* Enable Rx Traffic and interrupts on the NIC */ in s2io_card_up()
7163 DBG_PRINT(ERR_DBG, "%s: Starting NIC failed\n", dev->name); in s2io_card_up()
7210 * s2io_restart_nic - Resets the NIC.
7214 * function after 0.5 secs to reset the NIC. The idea is to reduce
7281 struct s2io_nic *sp = ring_data->nic; in rx_osm_handler()
7381 * NIC verifies if the Checksum of the received in rx_osm_handler()
7456 * status of the NIC is down or up. This is called by the Alarm
7598 * @nic: device private variable
7606 static int rts_ds_steer(struct s2io_nic *nic, u8 ds_codepoint, u8 ring) in rts_ds_steer() argument
7608 struct XENA_dev_config __iomem *bar0 = nic->bar0; in rts_ds_steer()
7713 /* Private member variable initialized to s2io NIC structure */ in s2io_init_nic()
7732 /* Initialize some PCI/PCI-X fields of the NIC. */ in s2io_init_nic()
7829 /* initialize the shared memory used by the NIC and the host */ in s2io_init_nic()
7872 /* Setting swapper control on the NIC, for proper reset operation */ in s2io_init_nic()
7979 /* reset Nic and bring it to known state */ in s2io_init_nic()