Lines Matching +full:msi +full:- +full:base +full:- +full:vec

2  * Copyright (c) 2003-2008 Chelsio, Inc. All rights reserved.
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
38 #include <linux/dma-mapping.h>
77 #define PORT_MASK ((1 << MAX_NPORTS) - 1)
99 CH_DEVICE(0x35, 6), /* T3C20-derived T3C10 */
100 CH_DEVICE(0x36, 3), /* S320E-CR */
101 CH_DEVICE(0x37, 7), /* N320E-G2 */
117 * order MSI-X, MSI, legacy pin interrupts. This parameter determines which
120 * msi = 2: choose from among all three options
121 * msi = 1: only consider MSI and pin interrupts
122 * msi = 0: force pin interrupts
124 static int msi = 2; variable
126 module_param(msi, int, 0644);
127 MODULE_PARM_DESC(msi, "whether to use MSI or MSI-X");
150 * link_report - show link status and link speed/duplex
163 switch (p->link_config.speed) { in link_report()
175 netdev_info(dev, "link up, %s, %s-duplex\n", in link_report()
176 s, p->link_config.duplex == DUPLEX_FULL in link_report()
184 t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset, 0, in enable_tx_fifo_drain()
186 t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, 0); in enable_tx_fifo_drain()
187 t3_write_reg(adapter, A_XGM_TX_CTRL + pi->mac.offset, F_TXEN); in enable_tx_fifo_drain()
188 t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, F_RXEN); in enable_tx_fifo_drain()
194 t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset, in disable_tx_fifo_drain()
200 struct net_device *dev = adap->port[port_id]; in t3_os_link_fault()
207 struct cmac *mac = &pi->mac; in t3_os_link_fault()
214 t3_xgm_intr_disable(adap, pi->port_id); in t3_os_link_fault()
216 pi->mac.offset); in t3_os_link_fault()
218 A_XGM_INT_CAUSE + pi->mac.offset, in t3_os_link_fault()
223 pi->mac.offset, in t3_os_link_fault()
225 t3_xgm_intr_enable(adap, pi->port_id); in t3_os_link_fault()
238 * t3_os_link_changed - handle link status changes
244 * @pause: the new flow-control setting
246 * This is the OS-dependent handler for link status changes. The OS
248 * then calls this handler for any OS-specific processing.
253 struct net_device *dev = adapter->port[port_id]; in t3_os_link_changed()
255 struct cmac *mac = &pi->mac; in t3_os_link_changed()
268 t3_xgm_intr_disable(adapter, pi->port_id); in t3_os_link_changed()
270 pi->mac.offset); in t3_os_link_changed()
272 A_XGM_INT_CAUSE + pi->mac.offset, in t3_os_link_changed()
276 A_XGM_INT_ENABLE + pi->mac.offset, in t3_os_link_changed()
278 t3_xgm_intr_enable(adapter, pi->port_id); in t3_os_link_changed()
284 t3_xgm_intr_disable(adapter, pi->port_id); in t3_os_link_changed()
285 t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset); in t3_os_link_changed()
287 A_XGM_INT_ENABLE + pi->mac.offset, in t3_os_link_changed()
291 pi->phy.ops->power_down(&pi->phy, 1); in t3_os_link_changed()
293 t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset); in t3_os_link_changed()
295 t3_link_start(&pi->phy, mac, &pi->link_config); in t3_os_link_changed()
306 * t3_os_phymod_changed - handle PHY module changes
310 * This is the OS-dependent handler for PHY module changes. It is
311 * invoked when a PHY module is removed or inserted for any OS-specific
320 const struct net_device *dev = adap->port[port_id]; in t3_os_phymod_changed()
323 if (pi->phy.modtype == phy_modtype_none) in t3_os_phymod_changed()
327 mod_str[pi->phy.modtype]); in t3_os_phymod_changed()
334 t3_mac_set_rx_mode(&pi->mac, dev); in cxgb_set_rxmode()
338 * link_start - enable a port
346 struct cmac *mac = &pi->mac; in link_start()
350 t3_mac_set_mtu(mac, dev->mtu); in link_start()
351 t3_mac_set_address(mac, LAN_MAC_IDX, dev->dev_addr); in link_start()
352 t3_mac_set_address(mac, SAN_MAC_IDX, pi->iscsic.mac_addr); in link_start()
354 t3_link_start(&pi->phy, mac, &pi->link_config); in link_start()
360 if (adapter->flags & USING_MSIX) { in cxgb_disable_msi()
361 pci_disable_msix(adapter->pdev); in cxgb_disable_msi()
362 adapter->flags &= ~USING_MSIX; in cxgb_disable_msi()
363 } else if (adapter->flags & USING_MSI) { in cxgb_disable_msi()
364 pci_disable_msi(adapter->pdev); in cxgb_disable_msi()
365 adapter->flags &= ~USING_MSI; in cxgb_disable_msi()
370 * Interrupt handler for asynchronous events used with MSI-X.
379 * Name the MSI-X interrupts.
385 strscpy(adap->msix_info[0].desc, adap->name, sizeof(adap->msix_info[0].desc)); in name_msix_vecs()
388 struct net_device *d = adap->port[j]; in name_msix_vecs()
391 for (i = 0; i < pi->nqsets; i++, msi_idx++) { in name_msix_vecs()
392 snprintf(adap->msix_info[msi_idx].desc, in name_msix_vecs()
393 sizeof(adap->msix_info[0].desc), in name_msix_vecs()
394 "%s-%d", d->name, pi->first_qset + i); in name_msix_vecs()
404 int nqsets = adap2pinfo(adap, i)->nqsets; in request_msix_data_irqs()
407 err = request_irq(adap->msix_info[qidx + 1].vec, in request_msix_data_irqs()
409 adap->sge.qs[qidx]. in request_msix_data_irqs()
411 adap->msix_info[qidx + 1].desc, in request_msix_data_irqs()
412 &adap->sge.qs[qidx]); in request_msix_data_irqs()
414 while (--qidx >= 0) in request_msix_data_irqs()
415 free_irq(adap->msix_info[qidx + 1].vec, in request_msix_data_irqs()
416 &adap->sge.qs[qidx]); in request_msix_data_irqs()
427 if (adapter->flags & USING_MSIX) { in free_irq_resources()
430 free_irq(adapter->msix_info[0].vec, adapter); in free_irq_resources()
432 n += adap2pinfo(adapter, i)->nqsets; in free_irq_resources()
435 free_irq(adapter->msix_info[i + 1].vec, in free_irq_resources()
436 &adapter->sge.qs[i]); in free_irq_resources()
438 free_irq(adapter->pdev->irq, adapter); in free_irq_resources()
446 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { in await_mgmt_replies()
447 if (!--attempts) in await_mgmt_replies()
448 return -ETIMEDOUT; in await_mgmt_replies()
459 unsigned long cnt = adap->sge.qs[0].rspq.offload_pkts; in init_tp_parity()
468 skb = adap->nofail_skb; in init_tp_parity()
473 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); in init_tp_parity()
475 req->mtu_idx = NMTUS - 1; in init_tp_parity()
476 req->iff = i; in init_tp_parity()
478 if (skb == adap->nofail_skb) { in init_tp_parity()
480 adap->nofail_skb = alloc_skb(sizeof(*greq), GFP_KERNEL); in init_tp_parity()
481 if (!adap->nofail_skb) in init_tp_parity()
491 skb = adap->nofail_skb; in init_tp_parity()
496 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); in init_tp_parity()
498 req->params = htonl(V_L2T_W_IDX(i)); in init_tp_parity()
500 if (skb == adap->nofail_skb) { in init_tp_parity()
502 adap->nofail_skb = alloc_skb(sizeof(*greq), GFP_KERNEL); in init_tp_parity()
503 if (!adap->nofail_skb) in init_tp_parity()
513 skb = adap->nofail_skb; in init_tp_parity()
518 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); in init_tp_parity()
520 req->l2t_idx = htonl(V_L2T_W_IDX(i)); in init_tp_parity()
522 if (skb == adap->nofail_skb) { in init_tp_parity()
524 adap->nofail_skb = alloc_skb(sizeof(*greq), GFP_KERNEL); in init_tp_parity()
525 if (!adap->nofail_skb) in init_tp_parity()
532 skb = adap->nofail_skb; in init_tp_parity()
537 greq->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); in init_tp_parity()
539 greq->mask = cpu_to_be64(1); in init_tp_parity()
543 if (skb == adap->nofail_skb) { in init_tp_parity()
545 adap->nofail_skb = alloc_skb(sizeof(*greq), GFP_KERNEL); in init_tp_parity()
553 return -ENOMEM; in init_tp_parity()
557 * setup_rss - configure RSS
570 unsigned int nq0 = adap2pinfo(adap, 0)->nqsets; in setup_rss()
571 unsigned int nq1 = adap->port[1] ? adap2pinfo(adap, 1)->nqsets : 1; in setup_rss()
595 struct sge_qset *qs = &adap->sge.qs[i]; in ring_dbs()
597 if (qs->adap) in ring_dbs()
599 t3_write_reg(adap, A_SG_KDOORBELL, F_SELEGRCNTX | V_EGRCNTX(qs->txq[j].cntxt_id)); in ring_dbs()
608 struct sge_qset *qs = &adap->sge.qs[i]; in init_napi()
610 if (qs->adap) in init_napi()
611 netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll); in init_napi()
619 adap->flags |= NAPI_INIT; in init_napi()
632 if (adap->sge.qs[i].adap) in quiesce_rx()
633 napi_disable(&adap->sge.qs[i].napi); in quiesce_rx()
640 if (adap->sge.qs[i].adap) in enable_all_napi()
641 napi_enable(&adap->sge.qs[i].napi); in enable_all_napi()
645 * setup_sge_qsets - configure SGE Tx/Rx/response queues
649 * We support multiple queue sets per port if we have MSI-X, otherwise
657 if (adap->params.rev > 0 && !(adap->flags & USING_MSI)) in setup_sge_qsets()
658 irq_idx = -1; in setup_sge_qsets()
661 struct net_device *dev = adap->port[i]; in setup_sge_qsets()
664 pi->qs = &adap->sge.qs[pi->first_qset]; in setup_sge_qsets()
665 for (j = 0; j < pi->nqsets; ++j, ++qset_idx) { in setup_sge_qsets()
667 (adap->flags & USING_MSIX) ? qset_idx + 1 : in setup_sge_qsets()
669 &adap->params.sge.qset[qset_idx], ntxq, dev, in setup_sge_qsets()
702 return -EPERM; in attr_store()
708 return -EINVAL; in attr_store()
722 struct adapter *adap = pi->adapter; \
734 struct adapter *adap = pi->adapter; in set_nfilters()
737 if (adap->flags & FULL_INIT_DONE) in set_nfilters()
738 return -EBUSY; in set_nfilters()
739 if (val && adap->params.rev == 0) in set_nfilters()
740 return -EINVAL; in set_nfilters()
741 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers - in set_nfilters()
743 return -EINVAL; in set_nfilters()
744 adap->params.mc5.nfilters = val; in set_nfilters()
757 struct adapter *adap = pi->adapter; in set_nservers()
759 if (adap->flags & FULL_INIT_DONE) in set_nservers()
760 return -EBUSY; in set_nservers()
761 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters - in set_nservers()
763 return -EINVAL; in set_nservers()
764 adap->params.mc5.nservers = val; in set_nservers()
782 CXGB3_ATTR_R(cam_size, t3_mc5_size(&adap->mc5));
783 CXGB3_ATTR_RW(nfilters, adap->params.mc5.nfilters, store_nfilters);
784 CXGB3_ATTR_RW(nservers, adap->params.mc5.nservers, store_nservers);
801 struct adapter *adap = pi->adapter; in tm_attr_show()
805 addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; in tm_attr_show()
816 v = (adap->params.vpd.cclk * 1000) / cpt; in tm_attr_show()
827 struct adapter *adap = pi->adapter; in tm_attr_store()
832 return -EPERM; in tm_attr_store()
838 return -EINVAL; in tm_attr_store()
903 struct port_info *pi = netdev_priv(adapter->port[idx]); in write_smt_entry()
907 return -ENOMEM; in write_smt_entry()
910 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); in write_smt_entry()
912 req->mtu_idx = NMTUS - 1; /* should be 0 but there's a T3 bug */ in write_smt_entry()
913 req->iff = idx; in write_smt_entry()
914 memcpy(req->src_mac0, adapter->port[idx]->dev_addr, ETH_ALEN); in write_smt_entry()
915 memcpy(req->src_mac1, pi->iscsic.mac_addr, ETH_ALEN); in write_smt_entry()
916 skb->priority = 1; in write_smt_entry()
917 offload_tx(&adapter->tdev, skb); in write_smt_entry()
932 unsigned int mtus = adapter->port[0]->mtu; in init_port_mtus()
934 if (adapter->port[1]) in init_port_mtus()
935 mtus |= adapter->port[1]->mtu << 16; in init_port_mtus()
948 skb = adap->nofail_skb; in send_pktsched_cmd()
950 return -ENOMEM; in send_pktsched_cmd()
953 req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_MNGT)); in send_pktsched_cmd()
954 req->mngt_opcode = FW_MNGTOPCODE_PKTSCHED_SET; in send_pktsched_cmd()
955 req->sched = sched; in send_pktsched_cmd()
956 req->idx = qidx; in send_pktsched_cmd()
957 req->min = lo; in send_pktsched_cmd()
958 req->max = hi; in send_pktsched_cmd()
959 req->binding = port; in send_pktsched_cmd()
961 if (skb == adap->nofail_skb) { in send_pktsched_cmd()
962 adap->nofail_skb = alloc_skb(sizeof(struct cpl_set_tcb_field), in send_pktsched_cmd()
964 if (!adap->nofail_skb) in send_pktsched_cmd()
965 ret = -ENOMEM; in send_pktsched_cmd()
978 for (j = 0; j < pi->nqsets; ++j) { in bind_qsets()
980 pi->first_qset + j, -1, in bind_qsets()
981 -1, i); in bind_qsets()
992 #define FW_FNAME "cxgb3/t3fw-" FW_VERSION ".bin"
995 #define TPSRAM_NAME "cxgb3/t3%c_psram-" TPSRAM_VERSION ".bin"
1000 MODULE_FIRMWARE("cxgb3/t3b_psram-" TPSRAM_VERSION ".bin");
1001 MODULE_FIRMWARE("cxgb3/t3c_psram-" TPSRAM_VERSION ".bin");
1026 struct adapter *adapter = phy->adapter; in t3_get_edc_fw()
1031 u16 *cache = phy->phy_cache; in t3_get_edc_fw()
1032 int i, ret = -EINVAL; in t3_get_edc_fw()
1036 ret = request_firmware(&fw, fw_name, &adapter->pdev->dev); in t3_get_edc_fw()
1038 dev_err(&adapter->pdev->dev, in t3_get_edc_fw()
1045 if (fw->size > size + 4) { in t3_get_edc_fw()
1047 (unsigned int)fw->size, size + 4); in t3_get_edc_fw()
1048 ret = -EINVAL; in t3_get_edc_fw()
1052 p = (const __be32 *)fw->data; in t3_get_edc_fw()
1053 for (csum = 0, i = 0; i < fw->size / sizeof(csum); i++) in t3_get_edc_fw()
1059 ret = -EINVAL; in t3_get_edc_fw()
1076 struct device *dev = &adap->pdev->dev; in upgrade_fw()
1084 ret = t3_load_fw(adap, fw->data, fw->size); in upgrade_fw()
1101 switch(adapter->params.rev) { in t3rev2char()
1117 struct device *dev = &adap->pdev->dev; in update_tpsram()
1134 ret = t3_check_tpsram(adap, tpsram->data, tpsram->size); in update_tpsram()
1138 ret = t3_set_proto_sram(adap, tpsram->data); in update_tpsram()
1157 * t3_synchronize_rx - wait for current Rx processing on a port to complete
1169 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) { in t3_synchronize_rx()
1170 struct sge_rspq *q = &adap->sge.qs[i].rspq; in t3_synchronize_rx()
1172 spin_lock_irq(&q->lock); in t3_synchronize_rx()
1173 spin_unlock_irq(&q->lock); in t3_synchronize_rx()
1180 struct adapter *adapter = pi->adapter; in cxgb_vlan_mode()
1182 if (adapter->params.rev > 0) { in cxgb_vlan_mode()
1183 t3_set_vlan_accel(adapter, 1 << pi->port_id, in cxgb_vlan_mode()
1191 adapter->port[i]->features & in cxgb_vlan_mode()
1200 * cxgb_up - enable the adapter
1213 if (!(adap->flags & FULL_INIT_DONE)) { in cxgb_up()
1215 if (err == -EINVAL) { in cxgb_up()
1223 if (err == -EINVAL) { in cxgb_up()
1242 t3_write_reg(adap, A_ULPRX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12)); in cxgb_up()
1249 cxgb_vlan_mode(adap->port[i], adap->port[i]->features); in cxgb_up()
1252 if (!(adap->flags & NAPI_INIT)) in cxgb_up()
1256 adap->flags |= FULL_INIT_DONE; in cxgb_up()
1261 if (adap->flags & USING_MSIX) { in cxgb_up()
1263 err = request_irq(adap->msix_info[0].vec, in cxgb_up()
1265 adap->msix_info[0].desc, adap); in cxgb_up()
1271 free_irq(adap->msix_info[0].vec, adap); in cxgb_up()
1275 err = request_irq(adap->pdev->irq, in cxgb_up()
1276 t3_intr_handler(adap, adap->sge.qs[0].rspq.polling), in cxgb_up()
1277 (adap->flags & USING_MSI) ? 0 : IRQF_SHARED, in cxgb_up()
1278 adap->name, adap); in cxgb_up()
1287 if (adap->params.rev >= T3_REV_C && !(adap->flags & TP_PARITY_INIT) && in cxgb_up()
1289 adap->flags |= TP_PARITY_INIT; in cxgb_up()
1291 if (adap->flags & TP_PARITY_INIT) { in cxgb_up()
1297 if (!(adap->flags & QUEUES_BOUND)) { in cxgb_up()
1308 adap->flags |= QUEUES_BOUND; in cxgb_up()
1324 spin_lock_irq(&adapter->work_lock); /* sync with PHY intr task */ in cxgb_down()
1326 spin_unlock_irq(&adapter->work_lock); in cxgb_down()
1339 timeo = adap->params.linkpoll_period ? in schedule_chk_task()
1340 (HZ * adap->params.linkpoll_period) / 10 : in schedule_chk_task()
1341 adap->params.stats_update_period * HZ; in schedule_chk_task()
1343 queue_delayed_work(cxgb3_wq, &adap->adap_check_task, timeo); in schedule_chk_task()
1349 struct adapter *adapter = pi->adapter; in offload_open()
1351 int adap_up = adapter->open_device_map & PORT_MASK; in offload_open()
1354 if (test_and_set_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) in offload_open()
1361 tdev->lldev = adapter->port[0]; in offload_open()
1367 t3_load_mtus(adapter, adapter->params.mtus, adapter->params.a_wnd, in offload_open()
1368 adapter->params.b_wnd, in offload_open()
1369 adapter->params.rev == 0 ? in offload_open()
1370 adapter->port[0]->mtu : 0xffff); in offload_open()
1373 if (sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group)) in offload_open()
1374 dev_dbg(&dev->dev, "cannot create sysfs group\n"); in offload_open()
1383 clear_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map); in offload_open()
1394 if (!test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) in offload_close()
1400 sysfs_remove_group(&tdev->lldev->dev.kobj, &offload_attr_group); in offload_close()
1403 flush_work(&td->tid_release_task); in offload_close()
1405 tdev->lldev = NULL; in offload_close()
1408 clear_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map); in offload_close()
1410 if (!adapter->open_device_map) in offload_close()
1420 struct adapter *adapter = pi->adapter; in cxgb_open()
1421 int other_ports = adapter->open_device_map & PORT_MASK; in cxgb_open()
1424 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) in cxgb_open()
1427 set_bit(pi->port_id, &adapter->open_device_map); in cxgb_open()
1434 netif_set_real_num_tx_queues(dev, pi->nqsets); in cxgb_open()
1435 err = netif_set_real_num_rx_queues(dev, pi->nqsets); in cxgb_open()
1439 t3_port_intr_enable(adapter, pi->port_id); in cxgb_open()
1444 cxgb3_event_notify(&adapter->tdev, OFFLOAD_PORT_UP, pi->port_id); in cxgb_open()
1451 struct adapter *adapter = pi->adapter; in __cxgb_close()
1454 if (!adapter->open_device_map) in __cxgb_close()
1458 t3_xgm_intr_disable(adapter, pi->port_id); in __cxgb_close()
1459 t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset); in __cxgb_close()
1461 t3_port_intr_disable(adapter, pi->port_id); in __cxgb_close()
1463 pi->phy.ops->power_down(&pi->phy, 1); in __cxgb_close()
1465 t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); in __cxgb_close()
1467 spin_lock_irq(&adapter->work_lock); /* sync with update task */ in __cxgb_close()
1468 clear_bit(pi->port_id, &adapter->open_device_map); in __cxgb_close()
1469 spin_unlock_irq(&adapter->work_lock); in __cxgb_close()
1471 if (!(adapter->open_device_map & PORT_MASK)) in __cxgb_close()
1472 cancel_delayed_work_sync(&adapter->adap_check_task); in __cxgb_close()
1474 if (!adapter->open_device_map) in __cxgb_close()
1477 cxgb3_event_notify(&adapter->tdev, OFFLOAD_PORT_DOWN, pi->port_id); in __cxgb_close()
1489 struct adapter *adapter = pi->adapter; in cxgb_get_stats()
1490 struct net_device_stats *ns = &dev->stats; in cxgb_get_stats()
1493 spin_lock(&adapter->stats_lock); in cxgb_get_stats()
1494 pstats = t3_mac_update_stats(&pi->mac); in cxgb_get_stats()
1495 spin_unlock(&adapter->stats_lock); in cxgb_get_stats()
1497 ns->tx_bytes = pstats->tx_octets; in cxgb_get_stats()
1498 ns->tx_packets = pstats->tx_frames; in cxgb_get_stats()
1499 ns->rx_bytes = pstats->rx_octets; in cxgb_get_stats()
1500 ns->rx_packets = pstats->rx_frames; in cxgb_get_stats()
1501 ns->multicast = pstats->rx_mcast_frames; in cxgb_get_stats()
1503 ns->tx_errors = pstats->tx_underrun; in cxgb_get_stats()
1504 ns->rx_errors = pstats->rx_symbol_errs + pstats->rx_fcs_errs + in cxgb_get_stats()
1505 pstats->rx_too_long + pstats->rx_jabber + pstats->rx_short + in cxgb_get_stats()
1506 pstats->rx_fifo_ovfl; in cxgb_get_stats()
1509 ns->rx_length_errors = pstats->rx_jabber + pstats->rx_too_long; in cxgb_get_stats()
1510 ns->rx_over_errors = 0; in cxgb_get_stats()
1511 ns->rx_crc_errors = pstats->rx_fcs_errs; in cxgb_get_stats()
1512 ns->rx_frame_errors = pstats->rx_symbol_errs; in cxgb_get_stats()
1513 ns->rx_fifo_errors = pstats->rx_fifo_ovfl; in cxgb_get_stats()
1514 ns->rx_missed_errors = pstats->rx_cong_drops; in cxgb_get_stats()
1517 ns->tx_aborted_errors = 0; in cxgb_get_stats()
1518 ns->tx_carrier_errors = 0; in cxgb_get_stats()
1519 ns->tx_fifo_errors = pstats->tx_underrun; in cxgb_get_stats()
1520 ns->tx_heartbeat_errors = 0; in cxgb_get_stats()
1521 ns->tx_window_errors = 0; in cxgb_get_stats()
1528 struct adapter *adapter = pi->adapter; in get_msglevel()
1530 return adapter->msg_enable; in get_msglevel()
1536 struct adapter *adapter = pi->adapter; in set_msglevel()
1538 adapter->msg_enable = val; in set_msglevel()
1601 return -EOPNOTSUPP; in get_sset_count()
1620 struct adapter *adapter = pi->adapter; in get_drvinfo()
1624 spin_lock(&adapter->stats_lock); in get_drvinfo()
1627 spin_unlock(&adapter->stats_lock); in get_drvinfo()
1629 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in get_drvinfo()
1630 strscpy(info->bus_info, pci_name(adapter->pdev), in get_drvinfo()
1631 sizeof(info->bus_info)); in get_drvinfo()
1633 snprintf(info->fw_version, sizeof(info->fw_version), in get_drvinfo()
1656 for (i = p->first_qset; i < p->first_qset + p->nqsets; ++i) in collect_sge_port_stats()
1657 tot += adapter->sge.qs[i].port_stats[idx]; in collect_sge_port_stats()
1665 struct adapter *adapter = pi->adapter; in get_stats()
1668 spin_lock(&adapter->stats_lock); in get_stats()
1669 s = t3_mac_update_stats(&pi->mac); in get_stats()
1670 spin_unlock(&adapter->stats_lock); in get_stats()
1672 *data++ = s->tx_octets; in get_stats()
1673 *data++ = s->tx_frames; in get_stats()
1674 *data++ = s->tx_mcast_frames; in get_stats()
1675 *data++ = s->tx_bcast_frames; in get_stats()
1676 *data++ = s->tx_pause; in get_stats()
1677 *data++ = s->tx_underrun; in get_stats()
1678 *data++ = s->tx_fifo_urun; in get_stats()
1680 *data++ = s->tx_frames_64; in get_stats()
1681 *data++ = s->tx_frames_65_127; in get_stats()
1682 *data++ = s->tx_frames_128_255; in get_stats()
1683 *data++ = s->tx_frames_256_511; in get_stats()
1684 *data++ = s->tx_frames_512_1023; in get_stats()
1685 *data++ = s->tx_frames_1024_1518; in get_stats()
1686 *data++ = s->tx_frames_1519_max; in get_stats()
1688 *data++ = s->rx_octets; in get_stats()
1689 *data++ = s->rx_frames; in get_stats()
1690 *data++ = s->rx_mcast_frames; in get_stats()
1691 *data++ = s->rx_bcast_frames; in get_stats()
1692 *data++ = s->rx_pause; in get_stats()
1693 *data++ = s->rx_fcs_errs; in get_stats()
1694 *data++ = s->rx_symbol_errs; in get_stats()
1695 *data++ = s->rx_short; in get_stats()
1696 *data++ = s->rx_jabber; in get_stats()
1697 *data++ = s->rx_too_long; in get_stats()
1698 *data++ = s->rx_fifo_ovfl; in get_stats()
1700 *data++ = s->rx_frames_64; in get_stats()
1701 *data++ = s->rx_frames_65_127; in get_stats()
1702 *data++ = s->rx_frames_128_255; in get_stats()
1703 *data++ = s->rx_frames_256_511; in get_stats()
1704 *data++ = s->rx_frames_512_1023; in get_stats()
1705 *data++ = s->rx_frames_1024_1518; in get_stats()
1706 *data++ = s->rx_frames_1519_max; in get_stats()
1708 *data++ = pi->phy.fifo_errors; in get_stats()
1718 *data++ = s->rx_cong_drops; in get_stats()
1720 *data++ = s->num_toggled; in get_stats()
1721 *data++ = s->num_resets; in get_stats()
1723 *data++ = s->link_faults; in get_stats()
1739 struct adapter *ap = pi->adapter; in get_regs()
1747 regs->version = 3 | (ap->params.rev << 10) | (is_pcie(ap) << 31); in get_regs()
1750 * We skip the MAC statistics registers because they are clear-on-read. in get_regs()
1751 * Also reading multi-register stats would need to synchronize with the in get_regs()
1771 return -EAGAIN; in restart_autoneg()
1772 if (p->link_config.autoneg != AUTONEG_ENABLE) in restart_autoneg()
1773 return -EINVAL; in restart_autoneg()
1774 p->phy.ops->autoneg_restart(&p->phy); in restart_autoneg()
1782 struct adapter *adapter = pi->adapter; in set_phys_id()
1807 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in get_link_ksettings()
1808 p->link_config.supported); in get_link_ksettings()
1809 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in get_link_ksettings()
1810 p->link_config.advertising); in get_link_ksettings()
1813 cmd->base.speed = p->link_config.speed; in get_link_ksettings()
1814 cmd->base.duplex = p->link_config.duplex; in get_link_ksettings()
1816 cmd->base.speed = SPEED_UNKNOWN; in get_link_ksettings()
1817 cmd->base.duplex = DUPLEX_UNKNOWN; in get_link_ksettings()
1821 cmd->link_modes.supported); in get_link_ksettings()
1823 cmd->base.port = (supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; in get_link_ksettings()
1824 cmd->base.phy_address = p->phy.mdio.prtad; in get_link_ksettings()
1825 cmd->base.autoneg = p->link_config.autoneg; in get_link_ksettings()
1868 struct link_config *lc = &p->link_config; in set_link_ksettings()
1872 cmd->link_modes.advertising); in set_link_ksettings()
1874 if (!(lc->supported & SUPPORTED_Autoneg)) { in set_link_ksettings()
1879 if (cmd->base.autoneg == AUTONEG_DISABLE) { in set_link_ksettings()
1880 u32 speed = cmd->base.speed; in set_link_ksettings()
1881 int cap = speed_duplex_to_caps(speed, cmd->base.duplex); in set_link_ksettings()
1882 if (lc->supported & cap) in set_link_ksettings()
1885 return -EINVAL; in set_link_ksettings()
1888 if (cmd->base.autoneg == AUTONEG_DISABLE) { in set_link_ksettings()
1889 u32 speed = cmd->base.speed; in set_link_ksettings()
1890 int cap = speed_duplex_to_caps(speed, cmd->base.duplex); in set_link_ksettings()
1892 if (!(lc->supported & cap) || (speed == SPEED_1000)) in set_link_ksettings()
1893 return -EINVAL; in set_link_ksettings()
1894 lc->requested_speed = speed; in set_link_ksettings()
1895 lc->requested_duplex = cmd->base.duplex; in set_link_ksettings()
1896 lc->advertising = 0; in set_link_ksettings()
1899 advertising &= lc->supported; in set_link_ksettings()
1901 return -EINVAL; in set_link_ksettings()
1902 lc->requested_speed = SPEED_INVALID; in set_link_ksettings()
1903 lc->requested_duplex = DUPLEX_INVALID; in set_link_ksettings()
1904 lc->advertising = advertising | ADVERTISED_Autoneg; in set_link_ksettings()
1906 lc->autoneg = cmd->base.autoneg; in set_link_ksettings()
1908 t3_link_start(&p->phy, &p->mac, lc); in set_link_ksettings()
1917 epause->autoneg = (p->link_config.requested_fc & PAUSE_AUTONEG) != 0; in get_pauseparam()
1918 epause->rx_pause = (p->link_config.fc & PAUSE_RX) != 0; in get_pauseparam()
1919 epause->tx_pause = (p->link_config.fc & PAUSE_TX) != 0; in get_pauseparam()
1926 struct link_config *lc = &p->link_config; in set_pauseparam()
1928 if (epause->autoneg == AUTONEG_DISABLE) in set_pauseparam()
1929 lc->requested_fc = 0; in set_pauseparam()
1930 else if (lc->supported & SUPPORTED_Autoneg) in set_pauseparam()
1931 lc->requested_fc = PAUSE_AUTONEG; in set_pauseparam()
1933 return -EINVAL; in set_pauseparam()
1935 if (epause->rx_pause) in set_pauseparam()
1936 lc->requested_fc |= PAUSE_RX; in set_pauseparam()
1937 if (epause->tx_pause) in set_pauseparam()
1938 lc->requested_fc |= PAUSE_TX; in set_pauseparam()
1939 if (lc->autoneg == AUTONEG_ENABLE) { in set_pauseparam()
1941 t3_link_start(&p->phy, &p->mac, lc); in set_pauseparam()
1943 lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX); in set_pauseparam()
1945 t3_mac_set_speed_duplex_fc(&p->mac, -1, -1, lc->fc); in set_pauseparam()
1955 struct adapter *adapter = pi->adapter; in get_sge_param()
1956 const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; in get_sge_param()
1958 e->rx_max_pending = MAX_RX_BUFFERS; in get_sge_param()
1959 e->rx_jumbo_max_pending = MAX_RX_JUMBO_BUFFERS; in get_sge_param()
1960 e->tx_max_pending = MAX_TXQ_ENTRIES; in get_sge_param()
1962 e->rx_pending = q->fl_size; in get_sge_param()
1963 e->rx_mini_pending = q->rspq_size; in get_sge_param()
1964 e->rx_jumbo_pending = q->jumbo_size; in get_sge_param()
1965 e->tx_pending = q->txq_size[0]; in get_sge_param()
1973 struct adapter *adapter = pi->adapter; in set_sge_param()
1977 if (e->rx_pending > MAX_RX_BUFFERS || in set_sge_param()
1978 e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || in set_sge_param()
1979 e->tx_pending > MAX_TXQ_ENTRIES || in set_sge_param()
1980 e->rx_mini_pending > MAX_RSPQ_ENTRIES || in set_sge_param()
1981 e->rx_mini_pending < MIN_RSPQ_ENTRIES || in set_sge_param()
1982 e->rx_pending < MIN_FL_ENTRIES || in set_sge_param()
1983 e->rx_jumbo_pending < MIN_FL_ENTRIES || in set_sge_param()
1984 e->tx_pending < adapter->params.nports * MIN_TXQ_ENTRIES) in set_sge_param()
1985 return -EINVAL; in set_sge_param()
1987 if (adapter->flags & FULL_INIT_DONE) in set_sge_param()
1988 return -EBUSY; in set_sge_param()
1990 q = &adapter->params.sge.qset[pi->first_qset]; in set_sge_param()
1991 for (i = 0; i < pi->nqsets; ++i, ++q) { in set_sge_param()
1992 q->rspq_size = e->rx_mini_pending; in set_sge_param()
1993 q->fl_size = e->rx_pending; in set_sge_param()
1994 q->jumbo_size = e->rx_jumbo_pending; in set_sge_param()
1995 q->txq_size[0] = e->tx_pending; in set_sge_param()
1996 q->txq_size[1] = e->tx_pending; in set_sge_param()
1997 q->txq_size[2] = e->tx_pending; in set_sge_param()
2007 struct adapter *adapter = pi->adapter; in set_coalesce()
2012 if (c->rx_coalesce_usecs * 10 > M_NEWTIMER) in set_coalesce()
2013 return -EINVAL; in set_coalesce()
2015 for (i = 0; i < pi->nqsets; i++) { in set_coalesce()
2016 qsp = &adapter->params.sge.qset[i]; in set_coalesce()
2017 qs = &adapter->sge.qs[i]; in set_coalesce()
2018 qsp->coalesce_usecs = c->rx_coalesce_usecs; in set_coalesce()
2030 struct adapter *adapter = pi->adapter; in get_coalesce()
2031 struct qset_params *q = adapter->params.sge.qset; in get_coalesce()
2033 c->rx_coalesce_usecs = q->coalesce_usecs; in get_coalesce()
2041 struct adapter *adapter = pi->adapter; in get_eeprom()
2044 e->magic = EEPROM_MAGIC; in get_eeprom()
2045 cnt = pci_read_vpd(adapter->pdev, e->offset, e->len, data); in get_eeprom()
2049 e->len = cnt; in get_eeprom()
2058 struct adapter *adapter = pi->adapter; in set_eeprom()
2063 if (eeprom->magic != EEPROM_MAGIC) in set_eeprom()
2064 return -EINVAL; in set_eeprom()
2066 aligned_offset = eeprom->offset & ~3; in set_eeprom()
2067 aligned_len = (eeprom->len + (eeprom->offset & 3) + 3) & ~3; in set_eeprom()
2069 if (aligned_offset != eeprom->offset || aligned_len != eeprom->len) { in set_eeprom()
2072 return -ENOMEM; in set_eeprom()
2073 err = pci_read_vpd(adapter->pdev, aligned_offset, aligned_len, in set_eeprom()
2077 memcpy(buf + (eeprom->offset & 3), data, eeprom->len); in set_eeprom()
2085 err = pci_write_vpd(adapter->pdev, aligned_offset, aligned_len, buf); in set_eeprom()
2096 wol->supported = 0; in get_wol()
2097 wol->wolopts = 0; in get_wol()
2098 memset(&wol->sopass, 0, sizeof(wol->sopass)); in get_wol()
2139 struct adapter *adapter = pi->adapter; in cxgb_siocdevprivate()
2143 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2146 return -EFAULT; in cxgb_siocdevprivate()
2153 int q1 = pi->first_qset; in cxgb_siocdevprivate()
2154 int nqsets = pi->nqsets; in cxgb_siocdevprivate()
2157 return -EPERM; in cxgb_siocdevprivate()
2159 return -EFAULT; in cxgb_siocdevprivate()
2161 return -EINVAL; in cxgb_siocdevprivate()
2163 return -EINVAL; in cxgb_siocdevprivate()
2178 return -EINVAL; in cxgb_siocdevprivate()
2180 if ((adapter->flags & FULL_INIT_DONE) && in cxgb_siocdevprivate()
2185 return -EBUSY; in cxgb_siocdevprivate()
2188 if (test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) { in cxgb_siocdevprivate()
2192 nqsets += pi->first_qset + pi->nqsets; in cxgb_siocdevprivate()
2197 return -EINVAL; in cxgb_siocdevprivate()
2198 if (t.qset_idx > q1 + nqsets - 1) in cxgb_siocdevprivate()
2199 return -EINVAL; in cxgb_siocdevprivate()
2201 q = &adapter->params.sge.qset[t.qset_idx]; in cxgb_siocdevprivate()
2204 q->rspq_size = t.rspq_size; in cxgb_siocdevprivate()
2206 q->fl_size = t.fl_size[0]; in cxgb_siocdevprivate()
2208 q->jumbo_size = t.fl_size[1]; in cxgb_siocdevprivate()
2210 q->txq_size[0] = t.txq_size[0]; in cxgb_siocdevprivate()
2212 q->txq_size[1] = t.txq_size[1]; in cxgb_siocdevprivate()
2214 q->txq_size[2] = t.txq_size[2]; in cxgb_siocdevprivate()
2216 q->cong_thres = t.cong_thres; in cxgb_siocdevprivate()
2219 &adapter->sge.qs[t.qset_idx]; in cxgb_siocdevprivate()
2221 q->coalesce_usecs = t.intr_lat; in cxgb_siocdevprivate()
2225 if (adapter->flags & USING_MSIX) in cxgb_siocdevprivate()
2226 q->polling = t.polling; in cxgb_siocdevprivate()
2229 if (adapter->params.rev == 0 && in cxgb_siocdevprivate()
2230 !(adapter->flags & USING_MSI)) in cxgb_siocdevprivate()
2234 q = &adapter->params.sge. in cxgb_siocdevprivate()
2236 q->polling = t.polling; in cxgb_siocdevprivate()
2243 dev->wanted_features |= NETIF_F_GRO; in cxgb_siocdevprivate()
2245 dev->wanted_features &= ~NETIF_F_GRO; in cxgb_siocdevprivate()
2254 int q1 = pi->first_qset; in cxgb_siocdevprivate()
2255 int nqsets = pi->nqsets; in cxgb_siocdevprivate()
2259 return -EFAULT; in cxgb_siocdevprivate()
2262 return -EINVAL; in cxgb_siocdevprivate()
2265 if (test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) { in cxgb_siocdevprivate()
2269 nqsets = pi->first_qset + pi->nqsets; in cxgb_siocdevprivate()
2274 return -EINVAL; in cxgb_siocdevprivate()
2277 q = &adapter->params.sge.qset[q1 + t.qset_idx]; in cxgb_siocdevprivate()
2278 t.rspq_size = q->rspq_size; in cxgb_siocdevprivate()
2279 t.txq_size[0] = q->txq_size[0]; in cxgb_siocdevprivate()
2280 t.txq_size[1] = q->txq_size[1]; in cxgb_siocdevprivate()
2281 t.txq_size[2] = q->txq_size[2]; in cxgb_siocdevprivate()
2282 t.fl_size[0] = q->fl_size; in cxgb_siocdevprivate()
2283 t.fl_size[1] = q->jumbo_size; in cxgb_siocdevprivate()
2284 t.polling = q->polling; in cxgb_siocdevprivate()
2285 t.lro = !!(dev->features & NETIF_F_GRO); in cxgb_siocdevprivate()
2286 t.intr_lat = q->coalesce_usecs; in cxgb_siocdevprivate()
2287 t.cong_thres = q->cong_thres; in cxgb_siocdevprivate()
2290 if (adapter->flags & USING_MSIX) in cxgb_siocdevprivate()
2291 t.vector = adapter->msix_info[q1 + t.qset_idx + 1].vec; in cxgb_siocdevprivate()
2293 t.vector = adapter->pdev->irq; in cxgb_siocdevprivate()
2296 return -EFAULT; in cxgb_siocdevprivate()
2304 return -EPERM; in cxgb_siocdevprivate()
2305 if (adapter->flags & FULL_INIT_DONE) in cxgb_siocdevprivate()
2306 return -EBUSY; in cxgb_siocdevprivate()
2308 return -EFAULT; in cxgb_siocdevprivate()
2310 return -EINVAL; in cxgb_siocdevprivate()
2312 (edata.val > 1 && !(adapter->flags & USING_MSIX))) in cxgb_siocdevprivate()
2313 return -EINVAL; in cxgb_siocdevprivate()
2316 if (adapter->port[i] && adapter->port[i] != dev) in cxgb_siocdevprivate()
2317 other_qsets += adap2pinfo(adapter, i)->nqsets; in cxgb_siocdevprivate()
2320 return -EINVAL; in cxgb_siocdevprivate()
2322 pi->nqsets = edata.val; in cxgb_siocdevprivate()
2325 if (adapter->port[i]) { in cxgb_siocdevprivate()
2327 pi->first_qset = first_qset; in cxgb_siocdevprivate()
2328 first_qset += pi->nqsets; in cxgb_siocdevprivate()
2338 edata.val = pi->nqsets; in cxgb_siocdevprivate()
2340 return -EFAULT; in cxgb_siocdevprivate()
2348 return -EPERM; in cxgb_siocdevprivate()
2350 return -EFAULT; in cxgb_siocdevprivate()
2352 return -EINVAL; in cxgb_siocdevprivate()
2369 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2371 return -EPERM; in cxgb_siocdevprivate()
2373 return -EBUSY; in cxgb_siocdevprivate()
2375 return -EFAULT; in cxgb_siocdevprivate()
2377 return -EINVAL; in cxgb_siocdevprivate()
2379 return -EINVAL; in cxgb_siocdevprivate()
2381 return -EINVAL; in cxgb_siocdevprivate()
2385 if (m.mtus[i] < m.mtus[i - 1]) in cxgb_siocdevprivate()
2386 return -EINVAL; in cxgb_siocdevprivate()
2388 memcpy(adapter->params.mtus, m.mtus, in cxgb_siocdevprivate()
2389 sizeof(adapter->params.mtus)); in cxgb_siocdevprivate()
2393 struct tp_params *p = &adapter->params.tp; in cxgb_siocdevprivate()
2397 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2398 m.tx_pg_sz = p->tx_pg_size; in cxgb_siocdevprivate()
2399 m.tx_num_pg = p->tx_num_pgs; in cxgb_siocdevprivate()
2400 m.rx_pg_sz = p->rx_pg_size; in cxgb_siocdevprivate()
2401 m.rx_num_pg = p->rx_num_pgs; in cxgb_siocdevprivate()
2402 m.pm_total = p->pmtx_size + p->chan_rx_size * p->nchan; in cxgb_siocdevprivate()
2404 return -EFAULT; in cxgb_siocdevprivate()
2409 struct tp_params *p = &adapter->params.tp; in cxgb_siocdevprivate()
2412 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2414 return -EPERM; in cxgb_siocdevprivate()
2415 if (adapter->flags & FULL_INIT_DONE) in cxgb_siocdevprivate()
2416 return -EBUSY; in cxgb_siocdevprivate()
2418 return -EFAULT; in cxgb_siocdevprivate()
2420 return -EINVAL; in cxgb_siocdevprivate()
2423 return -EINVAL; /* not power of 2 */ in cxgb_siocdevprivate()
2425 return -EINVAL; /* not 16KB or 64KB */ in cxgb_siocdevprivate()
2427 return -EINVAL; in cxgb_siocdevprivate()
2428 if (m.tx_num_pg == -1) in cxgb_siocdevprivate()
2429 m.tx_num_pg = p->tx_num_pgs; in cxgb_siocdevprivate()
2430 if (m.rx_num_pg == -1) in cxgb_siocdevprivate()
2431 m.rx_num_pg = p->rx_num_pgs; in cxgb_siocdevprivate()
2433 return -EINVAL; in cxgb_siocdevprivate()
2434 if (m.rx_num_pg * m.rx_pg_sz > p->chan_rx_size || in cxgb_siocdevprivate()
2435 m.tx_num_pg * m.tx_pg_sz > p->chan_tx_size) in cxgb_siocdevprivate()
2436 return -EINVAL; in cxgb_siocdevprivate()
2437 p->rx_pg_size = m.rx_pg_sz; in cxgb_siocdevprivate()
2438 p->tx_pg_size = m.tx_pg_sz; in cxgb_siocdevprivate()
2439 p->rx_num_pgs = m.rx_num_pg; in cxgb_siocdevprivate()
2440 p->tx_num_pgs = m.tx_num_pg; in cxgb_siocdevprivate()
2449 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2451 return -EPERM; in cxgb_siocdevprivate()
2452 if (!(adapter->flags & FULL_INIT_DONE)) in cxgb_siocdevprivate()
2453 return -EIO; /* need the memory controllers */ in cxgb_siocdevprivate()
2455 return -EFAULT; in cxgb_siocdevprivate()
2457 return -EINVAL; in cxgb_siocdevprivate()
2459 return -EINVAL; in cxgb_siocdevprivate()
2461 mem = &adapter->cm; in cxgb_siocdevprivate()
2463 mem = &adapter->pmrx; in cxgb_siocdevprivate()
2465 mem = &adapter->pmtx; in cxgb_siocdevprivate()
2467 return -EINVAL; in cxgb_siocdevprivate()
2474 t.version = 3 | (adapter->params.rev << 10); in cxgb_siocdevprivate()
2476 return -EFAULT; in cxgb_siocdevprivate()
2493 return -EFAULT; in cxgb_siocdevprivate()
2496 t.len -= chunk; in cxgb_siocdevprivate()
2505 return -EPERM; in cxgb_siocdevprivate()
2507 return -EAGAIN; in cxgb_siocdevprivate()
2509 return -EFAULT; in cxgb_siocdevprivate()
2511 return -EINVAL; in cxgb_siocdevprivate()
2525 return -EOPNOTSUPP; in cxgb_siocdevprivate()
2534 struct adapter *adapter = pi->adapter; in cxgb_ioctl()
2541 !mdio_phy_id_is_c45(data->phy_id) && in cxgb_ioctl()
2542 (data->phy_id & 0x1f00) && in cxgb_ioctl()
2543 !(data->phy_id & 0xe0e0)) in cxgb_ioctl()
2544 data->phy_id = mdio_phy_id_c45(data->phy_id >> 8, in cxgb_ioctl()
2545 data->phy_id & 0x1f); in cxgb_ioctl()
2548 return mdio_mii_ioctl(&pi->phy.mdio, data, cmd); in cxgb_ioctl()
2550 return -EOPNOTSUPP; in cxgb_ioctl()
2557 struct adapter *adapter = pi->adapter; in cxgb_change_mtu()
2560 if ((ret = t3_mac_set_mtu(&pi->mac, new_mtu))) in cxgb_change_mtu()
2562 WRITE_ONCE(dev->mtu, new_mtu); in cxgb_change_mtu()
2564 if (adapter->params.rev == 0 && offload_running(adapter)) in cxgb_change_mtu()
2565 t3_load_mtus(adapter, adapter->params.mtus, in cxgb_change_mtu()
2566 adapter->params.a_wnd, adapter->params.b_wnd, in cxgb_change_mtu()
2567 adapter->port[0]->mtu); in cxgb_change_mtu()
2574 struct adapter *adapter = pi->adapter; in cxgb_set_mac_addr()
2577 if (!is_valid_ether_addr(addr->sa_data)) in cxgb_set_mac_addr()
2578 return -EADDRNOTAVAIL; in cxgb_set_mac_addr()
2580 eth_hw_addr_set(dev, addr->sa_data); in cxgb_set_mac_addr()
2581 t3_mac_set_address(&pi->mac, LAN_MAC_IDX, dev->dev_addr); in cxgb_set_mac_addr()
2583 write_smt_entry(adapter, pi->port_id); in cxgb_set_mac_addr()
2604 netdev_features_t changed = dev->features ^ features; in cxgb_set_features()
2616 struct adapter *adapter = pi->adapter; in cxgb_netpoll()
2619 for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { in cxgb_netpoll()
2620 struct sge_qset *qs = &adapter->sge.qs[qidx]; in cxgb_netpoll()
2623 if (adapter->flags & USING_MSIX) in cxgb_netpoll()
2628 t3_intr_handler(adapter, qs->rspq.polling) (0, source); in cxgb_netpoll()
2641 struct net_device *dev = adapter->port[i]; in mac_stats_update()
2645 spin_lock(&adapter->stats_lock); in mac_stats_update()
2646 t3_mac_update_stats(&p->mac); in mac_stats_update()
2647 spin_unlock(&adapter->stats_lock); in mac_stats_update()
2657 struct net_device *dev = adapter->port[i]; in check_link_status()
2661 spin_lock_irq(&adapter->work_lock); in check_link_status()
2662 link_fault = p->link_fault; in check_link_status()
2663 spin_unlock_irq(&adapter->work_lock); in check_link_status()
2670 if (!(p->phy.caps & SUPPORTED_IRQ) && netif_running(dev)) { in check_link_status()
2672 t3_read_reg(adapter, A_XGM_INT_STATUS + p->mac.offset); in check_link_status()
2688 struct net_device *dev = adapter->port[i]; in check_t3b2_mac()
2697 status = t3b2_mac_watchdog_task(&p->mac); in check_t3b2_mac()
2699 p->mac.stats.num_toggled++; in check_t3b2_mac()
2701 struct cmac *mac = &p->mac; in check_t3b2_mac()
2703 t3_mac_set_mtu(mac, dev->mtu); in check_t3b2_mac()
2704 t3_mac_set_address(mac, LAN_MAC_IDX, dev->dev_addr); in check_t3b2_mac()
2706 t3_link_start(&p->phy, mac, &p->link_config); in check_t3b2_mac()
2708 t3_port_intr_enable(adapter, p->port_id); in check_t3b2_mac()
2709 p->mac.stats.num_resets++; in check_t3b2_mac()
2720 const struct adapter_params *p = &adapter->params; in t3_adap_check_task()
2724 adapter->check_task_cnt++; in t3_adap_check_task()
2729 if (!p->linkpoll_period || in t3_adap_check_task()
2730 (adapter->check_task_cnt * p->linkpoll_period) / 10 >= in t3_adap_check_task()
2731 p->stats_update_period) { in t3_adap_check_task()
2733 adapter->check_task_cnt = 0; in t3_adap_check_task()
2736 if (p->rev == T3_REV_B2) in t3_adap_check_task()
2748 struct cmac *mac = &adap2pinfo(adapter, port)->mac; in t3_adap_check_task()
2751 cause = t3_read_reg(adapter, A_XGM_INT_CAUSE + mac->offset); in t3_adap_check_task()
2754 mac->stats.rx_fifo_ovfl++; in t3_adap_check_task()
2758 t3_write_reg(adapter, A_XGM_INT_CAUSE + mac->offset, reset); in t3_adap_check_task()
2768 struct sge_qset *qs = &adapter->sge.qs[0]; in t3_adap_check_task()
2777 qs->fl[i].empty += (v & 1); in t3_adap_check_task()
2788 spin_lock_irq(&adapter->work_lock); in t3_adap_check_task()
2789 if (adapter->open_device_map & PORT_MASK) in t3_adap_check_task()
2791 spin_unlock_irq(&adapter->work_lock); in t3_adap_check_task()
2799 cxgb3_event_notify(&adapter->tdev, OFFLOAD_DB_FULL, 0); in db_full_task()
2807 cxgb3_event_notify(&adapter->tdev, OFFLOAD_DB_EMPTY, 0); in db_empty_task()
2817 cxgb3_event_notify(&adapter->tdev, OFFLOAD_DB_DROP, 0); in db_drop_task()
2821 * The delay is between 1000-2023 usecs. in db_drop_task()
2841 struct net_device *dev = adapter->port[i]; in ext_intr_task()
2845 t3_read_reg(adapter, A_XGM_INT_STATUS + p->mac.offset); in ext_intr_task()
2848 /* Re-enable link fault interrupts */ in ext_intr_task()
2855 spin_lock_irq(&adapter->work_lock); in ext_intr_task()
2856 if (adapter->slow_intr_mask) { in ext_intr_task()
2857 adapter->slow_intr_mask |= F_T3DBG; in ext_intr_task()
2860 adapter->slow_intr_mask); in ext_intr_task()
2862 spin_unlock_irq(&adapter->work_lock); in ext_intr_task()
2866 * Interrupt-context handler for external (PHY) interrupts.
2876 spin_lock(&adapter->work_lock); in t3_os_ext_intr_handler()
2877 if (adapter->slow_intr_mask) { in t3_os_ext_intr_handler()
2878 adapter->slow_intr_mask &= ~F_T3DBG; in t3_os_ext_intr_handler()
2880 adapter->slow_intr_mask); in t3_os_ext_intr_handler()
2881 queue_work(cxgb3_wq, &adapter->ext_intr_handler_task); in t3_os_ext_intr_handler()
2883 spin_unlock(&adapter->work_lock); in t3_os_ext_intr_handler()
2888 struct net_device *netdev = adapter->port[port_id]; in t3_os_link_fault_handler()
2891 spin_lock(&adapter->work_lock); in t3_os_link_fault_handler()
2892 pi->link_fault = 1; in t3_os_link_fault_handler()
2893 spin_unlock(&adapter->work_lock); in t3_os_link_fault_handler()
2901 test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) { in t3_adapter_error()
2902 cxgb3_event_notify(&adapter->tdev, OFFLOAD_STATUS_DOWN, 0); in t3_adapter_error()
2903 offload_close(&adapter->tdev); in t3_adapter_error()
2908 struct net_device *netdev = adapter->port[i]; in t3_adapter_error()
2917 adapter->flags &= ~FULL_INIT_DONE; in t3_adapter_error()
2922 pci_disable_device(adapter->pdev); in t3_adapter_error()
2929 if (pci_enable_device(adapter->pdev)) { in t3_reenable_adapter()
2930 dev_err(&adapter->pdev->dev, in t3_reenable_adapter()
2931 "Cannot re-enable PCI device after reset.\n"); in t3_reenable_adapter()
2934 pci_set_master(adapter->pdev); in t3_reenable_adapter()
2935 pci_restore_state(adapter->pdev); in t3_reenable_adapter()
2936 pci_save_state(adapter->pdev); in t3_reenable_adapter()
2946 return -1; in t3_reenable_adapter()
2955 struct net_device *netdev = adapter->port[i]; in t3_resume_ports()
2959 dev_err(&adapter->pdev->dev, in t3_resume_ports()
2968 cxgb3_event_notify(&adapter->tdev, OFFLOAD_STATUS_UP, 0); in t3_resume_ports()
2996 if (adapter->flags & FULL_INIT_DONE) { in t3_fatal_err()
3003 spin_lock(&adapter->work_lock); in t3_fatal_err()
3005 queue_work(cxgb3_wq, &adapter->fatal_error_handler_task); in t3_fatal_err()
3006 spin_unlock(&adapter->work_lock); in t3_fatal_err()
3016 * t3_io_error_detected - called when PCI error is detected
3038 * t3_io_slot_reset - called after the pci bus has been reset.
3041 * Restart the card from scratch, as if from a cold-boot.
3054 * t3_io_resume - called when traffic can start flowing again.
3087 int hwports = adap->params.nports; in set_nqsets()
3088 int nqsets = adap->msix_nvectors - 1; in set_nqsets()
3090 if (adap->params.rev > 0 && adap->flags & USING_MSIX) { in set_nqsets()
3106 pi->first_qset = j; in set_nqsets()
3107 pi->nqsets = nqsets; in set_nqsets()
3108 j = pi->first_qset + nqsets; in set_nqsets()
3110 dev_info(&adap->pdev->dev, in set_nqsets()
3125 vectors = pci_enable_msix_range(adap->pdev, entries, in cxgb_enable_msix()
3126 adap->params.nports + 1, vectors); in cxgb_enable_msix()
3131 adap->msix_info[i].vec = entries[i].vector; in cxgb_enable_msix()
3132 adap->msix_nvectors = vectors; in cxgb_enable_msix()
3140 "PCI", "PCI-X", "PCI-X ECC", "PCI-X 266", "PCI Express" in print_port_info()
3148 pci_variant[adap->params.pci.variant], in print_port_info()
3149 adap->params.pci.width); in print_port_info()
3151 snprintf(buf, sizeof(buf), "%s %dMHz/%d-bit", in print_port_info()
3152 pci_variant[adap->params.pci.variant], in print_port_info()
3153 adap->params.pci.speed, adap->params.pci.width); in print_port_info()
3156 struct net_device *dev = adap->port[i]; in print_port_info()
3159 if (!test_bit(i, &adap->registered_device_map)) in print_port_info()
3162 ai->desc, pi->phy.desc, in print_port_info()
3163 is_offload(adap) ? "R" : "", adap->params.rev, buf, in print_port_info()
3164 (adap->flags & USING_MSIX) ? " MSI-X" : in print_port_info()
3165 (adap->flags & USING_MSI) ? " MSI" : ""); in print_port_info()
3166 if (adap->name == dev->name && adap->params.vpd.mclk) in print_port_info()
3168 adap->name, t3_mc7_size(&adap->cm) >> 20, in print_port_info()
3169 t3_mc7_size(&adap->pmtx) >> 20, in print_port_info()
3170 t3_mc7_size(&adap->pmrx) >> 20, in print_port_info()
3171 adap->params.vpd.sn); in print_port_info()
3197 memcpy(pi->iscsic.mac_addr, dev->dev_addr, ETH_ALEN); in cxgb3_init_iscsi_mac()
3198 pi->iscsic.mac_addr[3] |= 0x80; in cxgb3_init_iscsi_mac()
3216 return -ENOMEM; in init_one()
3222 dev_err(&pdev->dev, "cannot enable PCI device\n"); in init_one()
3229 dev_info(&pdev->dev, "cannot obtain PCI resources\n"); in init_one()
3233 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in init_one()
3235 dev_err(&pdev->dev, "no usable DMA configuration\n"); in init_one()
3244 ai = t3_get_adapter_info(ent->driver_data); in init_one()
3248 err = -ENOMEM; in init_one()
3252 adapter->nofail_skb = in init_one()
3254 if (!adapter->nofail_skb) { in init_one()
3255 dev_err(&pdev->dev, "cannot allocate nofail buffer\n"); in init_one()
3256 err = -ENOMEM; in init_one()
3260 adapter->regs = ioremap(mmio_start, mmio_len); in init_one()
3261 if (!adapter->regs) { in init_one()
3262 dev_err(&pdev->dev, "cannot map device registers\n"); in init_one()
3263 err = -ENOMEM; in init_one()
3267 adapter->pdev = pdev; in init_one()
3268 adapter->name = pci_name(pdev); in init_one()
3269 adapter->msg_enable = dflt_msg_enable; in init_one()
3270 adapter->mmio_len = mmio_len; in init_one()
3272 mutex_init(&adapter->mdio_lock); in init_one()
3273 spin_lock_init(&adapter->work_lock); in init_one()
3274 spin_lock_init(&adapter->stats_lock); in init_one()
3276 INIT_LIST_HEAD(&adapter->adapter_list); in init_one()
3277 INIT_WORK(&adapter->ext_intr_handler_task, ext_intr_task); in init_one()
3278 INIT_WORK(&adapter->fatal_error_handler_task, fatal_error_task); in init_one()
3280 INIT_WORK(&adapter->db_full_task, db_full_task); in init_one()
3281 INIT_WORK(&adapter->db_empty_task, db_empty_task); in init_one()
3282 INIT_WORK(&adapter->db_drop_task, db_drop_task); in init_one()
3284 INIT_DELAYED_WORK(&adapter->adap_check_task, t3_adap_check_task); in init_one()
3286 for (i = 0; i < ai->nports0 + ai->nports1; ++i) { in init_one()
3291 err = -ENOMEM; in init_one()
3295 SET_NETDEV_DEV(netdev, &pdev->dev); in init_one()
3297 adapter->port[i] = netdev; in init_one()
3299 pi->adapter = adapter; in init_one()
3300 pi->port_id = i; in init_one()
3302 netdev->irq = pdev->irq; in init_one()
3303 netdev->mem_start = mmio_start; in init_one()
3304 netdev->mem_end = mmio_start + mmio_len - 1; in init_one()
3305 netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | in init_one()
3307 netdev->features |= netdev->hw_features | in init_one()
3309 netdev->vlan_features |= netdev->features & VLAN_FEAT; in init_one()
3311 netdev->features |= NETIF_F_HIGHDMA; in init_one()
3313 netdev->netdev_ops = &cxgb_netdev_ops; in init_one()
3314 netdev->ethtool_ops = &cxgb_ethtool_ops; in init_one()
3315 netdev->min_mtu = 81; in init_one()
3316 netdev->max_mtu = ETH_MAX_MTU; in init_one()
3317 netdev->dev_port = pi->port_id; in init_one()
3322 err = -ENODEV; in init_one()
3333 err = register_netdev(adapter->port[i]); in init_one()
3335 dev_warn(&pdev->dev, in init_one()
3337 adapter->port[i]->name); in init_one()
3343 if (!adapter->registered_device_map) in init_one()
3344 adapter->name = adapter->port[i]->name; in init_one()
3346 __set_bit(i, &adapter->registered_device_map); in init_one()
3349 if (!adapter->registered_device_map) { in init_one()
3350 dev_err(&pdev->dev, "could not register any net devices\n"); in init_one()
3351 err = -ENODEV; in init_one()
3356 cxgb3_init_iscsi_mac(adapter->port[i]); in init_one()
3362 __set_bit(OFFLOAD_DEVMAP_BIT, &adapter->registered_device_map); in init_one()
3367 if (msi > 1 && cxgb_enable_msix(adapter) == 0) in init_one()
3368 adapter->flags |= USING_MSIX; in init_one()
3369 else if (msi > 0 && pci_enable_msi(pdev) == 0) in init_one()
3370 adapter->flags |= USING_MSI; in init_one()
3374 err = sysfs_create_group(&adapter->port[0]->dev.kobj, in init_one()
3377 dev_err(&pdev->dev, "cannot create sysfs group\n"); in init_one()
3388 iounmap(adapter->regs); in init_one()
3389 for (i = ai->nports0 + ai->nports1 - 1; i >= 0; --i) in init_one()
3390 if (adapter->port[i]) in init_one()
3391 free_netdev(adapter->port[i]); in init_one()
3394 kfree_skb(adapter->nofail_skb); in init_one()
3415 sysfs_remove_group(&adapter->port[0]->dev.kobj, in remove_one()
3421 &adapter->open_device_map)) in remove_one()
3422 offload_close(&adapter->tdev); in remove_one()
3426 if (test_bit(i, &adapter->registered_device_map)) in remove_one()
3427 unregister_netdev(adapter->port[i]); in remove_one()
3434 if (adapter->port[i]) in remove_one()
3435 free_netdev(adapter->port[i]); in remove_one()
3437 iounmap(adapter->regs); in remove_one()
3438 kfree_skb(adapter->nofail_skb); in remove_one()